danielp Posted May 28, 2009 Share Posted May 28, 2009 Hey! big problem for me, but no problem for u! Here is some code opening one gui with button for second one. i am using hide/show for my guis. no problem so far... is there a way to change the behaviour for "$GUI_EVENT_CLOSE" of my second gui (ONLY SECOND). script should not exit on click. #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("Form1", 633, 449, 192, 124) $Button1 = GUICtrlCreateButton("open Gui2", 248, 200, 75, 25, $WS_GROUP) GUISetState(@SW_SHOW) $Form2 = GUICreate("Form2", 179, 142, 292, 224) $Label1 = GUICtrlCreateLabel("2222222", 64, 48, 58, 17) $Button2 = GUICtrlCreateButton("Close Gui2", 48, 72, 75, 25, $WS_GROUP) GUISetState(@SW_HIDE) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 GUISetState(@SW_SHOW,$Form2) Case $Button2 GUISetState(@SW_HIDE,$Form2) EndSwitch WEnd Thanks a lot Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 28, 2009 Moderators Share Posted May 28, 2009 danielp,Look in the Help file for GUIGetMsg and study the use of the "advanced" parameter. By using it you can tell which GUI is responding and so decide whether to exit the script or just hide the GUI.M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
danielp Posted May 28, 2009 Author Share Posted May 28, 2009 (edited) Sry for stupid question... You are right! sometimes the helpfile is your best friend... on the second look i decided to use eventmode. should be the best way for me. because i had little probs understanding it: here is my working code #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Opt("GUIOnEventMode", 1) $Form1 = GUICreate("Form1", 633, 449, 192, 124) GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSE") $btnOpenForm2 = GUICtrlCreateButton("open Gui2", 248, 200, 75, 25, $WS_GROUP) GUICtrlSetOnEvent($btnOpenForm2, "btnOpenForm2_click") GUISetState(@SW_SHOW) $Form2 = GUICreate("Form2", 179, 142, 292, 224) GUISetOnEvent($GUI_EVENT_CLOSE, "btnCloseForm2_click") $Label1 = GUICtrlCreateLabel("2222222", 64, 48, 58, 17) $btnCloseForm2 = GUICtrlCreateButton("Close Gui2", 48, 72, 75, 25, $WS_GROUP) GUICtrlSetOnEvent($btnCloseForm2, "btnCloseForm2_click") GUISetState(@SW_SHOW) Func btnOpenForm2_click() GUISetState(@SW_SHOW,$Form2) EndFunc Func btnCloseForm2_click() GUISetState(@SW_HIDE,$Form2) EndFunc Func CLOSE() Exit EndFunc While 1 Sleep(100) Wend . Edited May 28, 2009 by danielp Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 28, 2009 Moderators Share Posted May 28, 2009 danielp,Glad you solved it yourself - always more satisfying that way. :-)For interest, here is some code showing how to use the "advanced" parameter with GUIGetMsg():#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("Form1", 633, 449, 192, 124) $btnOpenForm2 = GUICtrlCreateButton("open Gui2", 248, 200, 75, 25, $WS_GROUP) GUISetState(@SW_SHOW) $Form2 = GUICreate("Form2", 179, 142, 292, 224) $Label1 = GUICtrlCreateLabel("2222222", 64, 48, 58, 17) $btnCloseForm2 = GUICtrlCreateButton("Close Gui2", 48, 72, 75, 25, $WS_GROUP) GUISetState(@SW_HIDE) While 1 ; Use the advanced parameter to get an array of information $aMsg = GUIGetMsg(1) ; The [0] element of the array is the Event/ControlID Switch $aMsg[0] Case $btnOpenForm2 GUISetState(@SW_SHOW,$Form2) Case $btnCloseForm2 GUISetState(@SW_HIDE,$Form2) Case $GUI_EVENT_CLOSE ; The [1] element of the array is the window handle If $aMsg[1] = $Form2 Then GUISetState(@SW_HIDE,$Form2) Else Exit EndIf EndSwitch WendIt may come in handy some time. ;-)M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now