Sign in to follow this  
Followers 0
IndyUK

Modal Form

5 posts in this topic

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

Share this post


Link to post
Share on other sites



You need to make the second window a child window and disable the parent window. There are plenty of examples for child windows all over the forum.


[font="Verdana"] [size="2"]"[/size][/font]Failure is not an option -- it comes packaged with Windows"[font="Verdana"][size="2"] Gecko Web Browser[/size][/font][font="Verdana"][size="2"], [/size][/font][font="Verdana"][size="2"]Yahtzee![/size][/font][font="Verdana"][size="2"], Toolbar Launcher (like RocketDock)[/size][/font][font="Verdana"][size="2"]Internet Blocker, Simple Calculator, Local Weather, Easy GDI+ GUI [/size][/font][font="Verdana"][size="2"]Triangle Solver, TCP File Transfer, [/size][/font][font="Verdana"][size="2"]Valuater's Autoit Wrappers[/size][/font][font="Verdana"][size="3"][size="2"][size="2"]OOP In AutoIt[/size][/size][/size][/font][font="Verdana"][size="2"][size="1"]Using Windows XP SP3, 1GB RAM, AMD Athlon Processor @ 2.1 GHzCheck me out at gadgets.freehostrocket.com[/size][/size][/font]

Share this post


Link to post
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)

Share this post


Link to post
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

Share this post


Link to post
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.

Share this post


Link to post
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
Sign in to follow this  
Followers 0