Digisoul Posted May 3, 2010 Share Posted May 3, 2010 Hello There, i want to know that how can i manually send the $GUI_EVENT_CLOSE msg to my GUI ? for example i have 1 button, & when i press the button it will fire $GUI_EVENT_CLOSE ? Thanks in advance 73 108 111 118 101 65 117 116 111 105 116 Link to comment Share on other sites More sharing options...
enaiman Posted May 3, 2010 Share Posted May 3, 2010 Taken from help examples and modified just a little bit: #include <GUIConstantsEx.au3> Opt('MustDeclareVars', 1) Example() Func Example() Local $Button_1, $msg GUICreate("My GUI Button") ; will create a dialog box that when displayed is centered Opt("GUICoordMode", 2) $Button_1 = GUICtrlCreateButton("Exit", 10, 30, 100) GUISetState() ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Button_1 Exit EndSelect WEnd EndFunc ;==>Example SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script wannabe "Unbeatable" Tic-Tac-Toe Paper-Scissor-Rock ... try to beat it anyway :) Link to comment Share on other sites More sharing options...
Digisoul Posted May 4, 2010 Author Share Posted May 4, 2010 Taken from help examples and modified just a little bit: #include <GUIConstantsEx.au3> Opt('MustDeclareVars', 1) Example() Func Example() Local $Button_1, $msg GUICreate("My GUI Button") ; will create a dialog box that when displayed is centered Opt("GUICoordMode", 2) $Button_1 = GUICtrlCreateButton("Exit", 10, 30, 100) GUISetState() ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Button_1 Exit EndSelect WEnd EndFunc ;==>Example Thanks enaiman for your kind reply, here is a example code , may its clear what i am trying to do #include <GUIConstantsEx.au3> Opt('MustDeclareVars', 1) Global $hwnd Example() Func Example() Local $Button_1, $msg $hwnd = GUICreate("My GUI Button") ; will create a dialog box that when displayed is centered Opt("GUICoordMode", 2) $Button_1 = GUICtrlCreateButton("Exit", 10, 30, 100) GUISetState() ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE MsgBox(0,"","test") Case $msg = $Button_1 function() EndSelect WEnd EndFunc Func function() ;some work if false then send $GUI_EVENT_CLOSE to $hwnd EndFunc 73 108 111 118 101 65 117 116 111 105 116 Link to comment Share on other sites More sharing options...
Spiff59 Posted May 4, 2010 Share Posted May 4, 2010 Thanks enaiman for your kind reply, here is a example code , may its clear what i am trying to do I'm not aware of a way to push a value onto the event stack, so you might have to do something like: #include <GUIConstantsEx.au3> Opt('MustDeclareVars', 1) Global $hwnd, $msg Example() Func Example() Local $Button_1, $msg $hwnd = GUICreate("My GUI Button") ; will create a dialog box that when displayed is centered Opt("GUICoordMode", 2) $Button_1 = GUICtrlCreateButton("Exit", 10, 30, 100) GUISetState() ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() Select Case $msg = $Button_1 If function() = $GUI_EVENT_CLOSE then ContinueCase Case $msg = $GUI_EVENT_CLOSE MsgBox(0,"","test") EndSelect WEnd EndFunc Func function() ;some work if false then send $GUI_EVENT_CLOSE to $hwnd Return($GUI_EVENT_CLOSE) EndFunc But that is dependant upon placing the exit-case right after the case that calls the function. It might be cleaner to simply use a flag: expandcollapse popup#include <GUIConstantsEx.au3> Opt('MustDeclareVars', 1) Global $hwnd, $msg, $exit Example() Func Example() Local $Button_1, $msg $hwnd = GUICreate("My GUI Button") ; will create a dialog box that when displayed is centered Opt("GUICoordMode", 2) $Button_1 = GUICtrlCreateButton("Exit", 10, 30, 100) GUISetState() ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() Select Case $msg = $Button_1 function() Case $msg = $GUI_EVENT_CLOSE $exit = True EndSelect If $exit Then MsgBox(0,"","test") $exit = False EndIf WEnd EndFunc Func function() ;some work if false then send $GUI_EVENT_CLOSE to $hwnd $exit = True EndFunc Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted May 4, 2010 Share Posted May 4, 2010 (edited) You could probably _SendMessage something (WM_QUIT?) but a simple WinClose() would also fire off $GUI_EVENT_CLOSE. Func function() WinClose($hwnd) EndFunc Edited May 4, 2010 by AdmiralAlkex .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
Digisoul Posted May 4, 2010 Author Share Posted May 4, 2010 You could probably _SendMessage something (WM_QUIT?) but a simple WinClose() would also fire off $GUI_EVENT_CLOSE. Func function() WinClose($hwnd) EndFunc Awesome! it was so simple 73 108 111 118 101 65 117 116 111 105 116 Link to comment Share on other sites More sharing options...
enaiman Posted May 4, 2010 Share Posted May 4, 2010 I guess GUIDelete($hwnd) would do the same thing if the GUI you're trying to close it's the one you created. If it is another window, then Yes, WinClose is the solution. Anyway - glad you figured it out. SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script wannabe "Unbeatable" Tic-Tac-Toe Paper-Scissor-Rock ... try to beat it anyway :) 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