nwbyy

Close button not working

4 posts in this topic

#1 ·  Posted

Hello.

My PC has windows 7 home 64bits.

I created serval little GUIs who all have this problem.

No way to close them with the red button on the right top.

Until now I always added a "close" button using "exit" function, thinking that soon or late I will get berind this problem, but no :-(

I began learning with this script:

 

#include <GUIConstants.au3>

$main_GUI = GUICreate("main_GUI", 250, 250, -1, -1, BitXOR($GUI_SS_DEFAULT_GUI, $WS_MINIMIZEBOX))
$b_1 = GUICtrlCreateButton("Show Child GUI", 10, 20,120, 30)
$x = GUICtrlCreateButton("Exit", 10, 60,120, 30)
GUISetState(@SW_SHOW, $main_GUI)
$a = WinGetPos ($main_GUI)
$child_GUI = GUICreate("Child GUI",200,100,$a[0] + 210 , $a[1],$WS_POPUPWINDOW + $WS_THICKFRAME)
GUICtrlCreateLabel("This is the Child GUI", 50, 30,120, 30)
$b_2 = GUICtrlCreateButton("Close Child GUI", 40, 60,120, 30)
GUISetState(@SW_HIDE, $child_GUI)

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $x
            Exit
        Case $msg = $b_1
            GUISetState (@SW_SHOW, $child_GUI)
            GUICtrlSetState ($b_1 , $gui_disable)
        Case $msg = $b_2
            GUISetState (@SW_HIDE, $child_GUI)
            GUICtrlSetState ($b_1 , $gui_enable)
    EndSelect
WEnd

 

What is missing to get the "close" button work?

Thanks.

Share this post


Link to post
Share on other sites



#2 ·  Posted

You need to read the messages of the child window for that:

#include <GUIConstants.au3>

$main_GUI = GUICreate("main_GUI", 250, 250, -1, -1, BitXOR($GUI_SS_DEFAULT_GUI, $WS_MINIMIZEBOX))
$b_1 = GUICtrlCreateButton("Show Child GUI", 10, 20,120, 30)
$x = GUICtrlCreateButton("Exit", 10, 60,120, 30)
GUISetState(@SW_SHOW, $main_GUI)
$a = WinGetPos ($main_GUI)
$child_GUI = GUICreate("Child GUI",200,100,$a[0] + 210 , $a[1],$WS_POPUPWINDOW + $WS_THICKFRAME)
GUICtrlCreateLabel("This is the Child GUI", 50, 30,120, 30)
$b_2 = GUICtrlCreateButton("Close Child GUI", 40, 60,120, 30)
GUISetState(@SW_HIDE, $child_GUI)

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $x
            Exit
        Case $msg = $b_1
            GUISetState (@SW_SHOW, $child_GUI)
            GUICtrlSetState ($b_1 , $gui_disable)
    EndSelect
    $msg = GUIGetMsg($child_GUI)
    Select
        Case $msg = $b_2
            ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $b_2 = ' & $b_2 & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console
            GUISetState (@SW_HIDE, $child_GUI)
            GUICtrlSetState ($b_1 , $gui_enable)
    EndSelect
WEnd

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#3 ·  Posted

 

1 hour ago, nwbyy said:

No way to close them with the red button on the right top

The close button ( "the red button on the right top" ) should be addressed from gui events, see gui event messages

Case $msg = $GUI_EVENT_CLOSE
 Exit

 

Share this post


Link to post
Share on other sites

#4 ·  Posted

Great!

That does it.

 

Thank you both for the answers.

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