Jump to content
Sign in to follow this  
Digisoul

question about $GUI_EVENT_CLOSE

Recommended Posts

Digisoul

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

Share this post


Link to post
Share on other sites
enaiman

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 :)

Share this post


Link to post
Share on other sites
Digisoul

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

Share this post


Link to post
Share on other sites
Spiff59

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:

#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

Share this post


Link to post
Share on other sites
AdmiralAlkex

You could probably _SendMessage something (WM_QUIT?) but a simple WinClose() would also fire off $GUI_EVENT_CLOSE.

Func function()
    WinClose($hwnd)
EndFunc
Edited by AdmiralAlkex

Share this post


Link to post
Share on other sites
Digisoul

You could probably _SendMessage something (WM_QUIT?) but a simple WinClose() would also fire off $GUI_EVENT_CLOSE.

Func function()
    WinClose($hwnd)
EndFunc

Awesome!Posted Image it was so simple Posted Image

73 108 111 118 101 65 117 116 111 105 116

Share this post


Link to post
Share on other sites
enaiman

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 :)

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.