Jump to content

question about $GUI_EVENT_CLOSE


Recommended Posts

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

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

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

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
Link to comment
Share on other sites

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
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...