Jump to content

Close button not working


Recommended Posts

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.

Link to comment
Share on other sites

  • Developers

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

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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