Jump to content

Modal Form


IndyUK
 Share

Recommended Posts

Hi All,

I've got a main form for my script which works fine. However, I want to open another form from it and have that form be modal. I'm mean modal in the sense that the focus cannot move from it. I looked at the various styles for GUICreate and none seem to do what I need. The closest was the $WS_EX_TOPMOST style but that still allows you to move the focus to other forms although leaves the form on-top. Any ideas which style I need to use?

Thanks

Link to comment
Share on other sites

I've setup the window as a child window but I can still operate the parent window even though the child window is on top. This is the line I'm using to create the child window. What am I still doing wrong?

$frmAddNewScript = GUICreate("Add New Script", 427, 437, 220, 133, $DS_SETFOREGROUND, "", $Form1)
Link to comment
Share on other sites

What you are doing wrong is not providing a reproduction script. You should be punished for your insolence!!

Joking aside, here's what you wanted.. Can has treat please.

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Array.au3>

$main = GUICreate("MyGUI", 392, 322)
$Button_1 = GUICtrlCreateButton("Input", 140, 190, 70, 30)
GUISetState()

$popup = GUICreate("PopUP", 191, 185, -1, -1, -1, $WS_EX_TOPMOST)

While 1
    $msg = GUIGetMsg(1)
    Select
        Case $msg[1] = $popup And $msg[0] = $GUI_EVENT_CLOSE ; Modal close
            GUISetState(@SW_HIDE, $popup)
            GUISetState(@SW_ENABLE, $main)
            WinActivate($main)
        Case $msg[1] = $main And $msg[0] = $GUI_EVENT_CLOSE ; Main close
            ExitLoop
        Case $msg[1] = $main And $msg[0] = $Button_1 ; Input click, modal open
            GUISetState(@SW_DISABLE, $main)
            GUISetState(@SW_SHOW, $popup)
    EndSelect
WEnd
Exit
Link to comment
Share on other sites

What you are doing wrong is not providing a reproduction script. You should be punished for your insolence!!

Joking aside, here's what you wanted.. Can has treat please.

Thank you very much. This has worked perfectly.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...