Sign in to follow this  
Followers 0
HockeyFan

Help with GUI Controls in a child window

3 posts in this topic

Can someone help me with why my second (i guess child) GUI window is not allowing my Func calls to work? I have a main GUI window from which I have buttons that call other Functions, generating a secondary GUI window; but when the second GUI window is active, the buttons do not work. :)

Not sure if this is a parent/child relationship problem or just bad coding. :D ...well that's obvious! :P

Here is what I have so far:

; Script Start
#include <GUIConstants.au3>
#Include <Misc.au3>
Opt("GUIOnEventMode", 1)
Opt("WinWaitDelay", 500)
Opt("SendKeyDelay", 20)
Opt("WinTitleMatchMode", 1)
$font = "Arial Bold"
Local $Count
Local $GuiExit

AutoItSetOption("TrayIconHide", 0) ;0 = show icon (default), 1 = hide icon.
Break(1) ;1 = Break is enabled (user can quit) (default), 0 = Break is disabled (user cannot quit).
WinMinimizeAll()
;Main Message Screen Text
$TextLine1 = "" & @CR & "Line1..."
$TextLine2 = "Software Title"
$TextLine3 = "Line3."
$TextLine4 = "Please note..." & @CR & "Line4."
$TextLine5 = 'Line5.'
$TextLine6 = "Line6A," & @CR & "Line6B." & @CR & "" & @CR & 'Click the "OK" button to begin installation or the "Exit" button to quit.'

;Main GUI Message Screen Creation
$GuiWindow = GUICreate("Attention!", 650, 430, -1, -1)
GUISetBkColor (0xCC99FF)
$GuiLine1 = GUICtrlCreateLabel($TextLine1, 0, 0, 650, 40, $SS_CENTER)
GUICtrlSetFont(-1, 12, 400, 0, $font)
GUICtrlSetColor ($GuiLine1, 0x000000)
$GuiLine2 = GUICtrlCreateLabel($TextLine2, 0, 45, 650, 25, $SS_CENTER)
GUICtrlSetFont(-1, 14, 400, 0, $font)
GUICtrlSetColor ($GuiLine2, 0xCC3300 )
$GuiLine3 = GUICtrlCreateLabel($TextLine3, 0, 75, 650, 60, $SS_CENTER)
GUICtrlSetFont(-1, 12, 400, 0, $font)
GUICtrlSetColor ($GuiLine3, 0x000000)
$GuiLine4 = GUICtrlCreateLabel($TextLine4, 0, 140, 650, 50, $SS_CENTER)
GUICtrlSetFont(-1, 14, 400, 0, $font)
GUICtrlSetColor ($GuiLine4, 0x000080 )
$GuiLine5 = GUICtrlCreateLabel($TextLine5, 0, 190, 650, 20, $SS_CENTER)
GUICtrlSetFont(-1, 12, 400, 0, $font)
GUICtrlSetColor ($GuiLine5, 0xFF0000)
$GuiLine6 = GUICtrlCreateLabel($TextLine6, 0, 250, 650, 130, $SS_CENTER)
GUICtrlSetFont(-1, 12, 400, 0, $font)
GUICtrlSetColor ($GuiLine6, 0x000000)
$Okbutton = GUICtrlCreateButton("OK", 235, 380, 80)
$ExitButton = GUICtrlCreateButton("Exit", 335, 380, 80)
$TestButton = GUICtrlCreateButton("Connection Test", 270, 218, 110)
GUICtrlSetOnEvent($ExitButton, "ExitClicked")
GUICtrlSetOnEvent($OKbutton, "OKClicked")
GUICtrlSetOnEvent($TestButton, "TestConnection")
GUISetOnEvent($GUI_EVENT_MINIMIZE, "Minimize")
GUISetOnEvent($GUI_EVENT_CLOSE, "ExitClicked")
GUISetState(@SW_SHOW)

While 1
    Sleep(1000)
WEnd

Exit

Func InstallProgram()
     ;For Testing purposes only.
     ;Run Program Install
     MsgBox(0,"Test", "Program install would run here!")
     Exit
EndFunc

Func TestConnection()
     SplashTextOn("Please wait...", @CR & "Testing in progress... ", 300, 80, -1, -1, 0, "", 14, 400)
     ; 0 = not connected, 1 is connected.
     $IsCon=DllCall("WinInet.dll","int","InternetGetConnectedState","int_ptr",0,"int",0)
     Sleep(1000)
     ;Ping failure...Ping returns 0, Success, Returns the roundtrip-time in milliseconds (greater than 0).
     $IPTest = Ping("172.31.1.11")
     SplashOff()
     If $IPTest > 0 Then  
    MsgBox(0,"Connection Test...", "Connected!" & @CR & "" & @CR & "You are connected to XXXXX's network." & @CR & "" & @CR & "Please click the OK button to start the install.")
    GUIDelete($GuiWindow)
     Else
    If $IsCon[0] = 0 Then
        MsgBox(0,"Connection Test...", "Error!" & @CR & "" & @CR & "You are NOT connected to XXXXX's network or the Internet." & @CR & "" & @CR & "Please connect to XXXXX's network and run this program again.")
    Else
        MsgBox(0,"Connection Test...", "Error!" & @CR & "" & @CR & "You are connected to the Internet, but NOT connected to XXXXX's network." & @CR & "" & @CR & "Please connect to XXXXX's network and run this program again.")
    EndIf
     EndIf
EndFunc

Func ExitClicked()
    ;GUISetState(@SW_HIDE, $GuiWindow)
    $GuiExit = GUICreate("Exit?", 420, 180, -1, -1, $DS_SETFOREGROUND,$WS_EX_TOPMOST)
    GUISetBkColor (0x000000)
    $ExitText = "Are you sure you want to cancel this installation?" & @CR & "" & @CR & "It's very important that you install this software!"
    $ExitMessage = GUICtrlCreateLabel($ExitText, 20, 20, 390, 75)
    GUICtrlSetColor ($ExitMessage, 0xff0000)
    GUICtrlSetFont(-1, 12, 400, 0, $font)
    $ExitYes = GUICtrlCreateButton("Yes", 100, 100, 100, 30)
    $ExitNo = GUICtrlCreateButton("No", 220, 100, 100, 30)
    GUICtrlSetOnEvent($ExitYes, "ExitYes")
    GUICtrlSetOnEvent($ExitNo, "ExitNo")
    GUISwitch($GuiExit)
    GUISetState(@SW_SHOW,$GuiExit)
    ;GUISetState()

    While 1
        Sleep(100)
    WEnd
    
EndFunc   ;==>CLOSEClicked

Func Minimize()
    Sleep(60000)
    SoundPlay(@WindowsDir & "\media\Windows XP Balloon.wav",1)
    GUISetState(@SW_RESTORE)
    GUISetState()
EndFunc

Func OKClicked()
    GUICreate("", 400, 316, -1, -1, $WS_EX_TOPMOST)
    GUISetBkColor(0xFFFFFF)
    $GUIMainText = GUICtrlCreateLabel("Please type the following information: ", 20, 20, 350, 30)
    GUICtrlSetFont(-1, 14, 400, 0, $font)
    GUICtrlSetColor($GUIMainText, 0xFF0000)
    $LabelFirstName = GUICtrlCreateLabel("First Name:", 20, 70, 350, 20)
    GUICtrlSetFont(-1, 12, 400, 0, $font)
    $InputFirstName = GUICtrlCreateInput("", 20, 90, 350, 30)
    GUICtrlSetFont(-1, 12, 400, 0, $font)
    GUICtrlSetColor($InputFirstName, 0x0033FF)
    $LabelLastName = GUICtrlCreateLabel("Last Name:", 20, 140, 350, 20)
    GUICtrlSetFont(-1, 12, 400, 0, $font)
    $InputlastName = GUICtrlCreateInput("", 20, 160, 350, 30)
    GUICtrlSetFont(-1, 12, 400, 0, $font)
    GUICtrlSetColor($InputlastName, 0x0033FF)
    $OKButton6 = GUICtrlCreateButton("OK", 135, 225, 120, 30)
    GUICtrlSetOnEvent($OKButton6, "InstallProgram")
    GUICtrlSetState($OKButton6, $GUI_DISABLE)
    GUISetState()

    While 1
        Sleep(10)
        $TypedName = GUICtrlRead($InputlastName)
        If $TypedName <> "" And BitAND(GUICtrlGetState($OKButton6), $GUI_DISABLE) = $GUI_DISABLE Then
            GUICtrlSetState($OKButton6, $GUI_ENABLE)
        ElseIf $TypedName = "" And BitAND(GUICtrlGetState($OKButton6), $GUI_ENABLE) = $GUI_ENABLE Then
            GUICtrlSetState($OKButton6, $GUI_DISABLE)
        EndIf
    WEnd
EndFunc

Func ExitYes()
    ;FileDelete("C:\Software\HAT\........")
    ;FileDelete("C:\Software\HAT\......")
    ;FileDelete("C:\Software\HAT\......")
    ;Call ("SelfDelete")
    Exit
EndFunc

Func ExitNO()
    ;GUISetState(@SW_SHOW, $GuiWindow)
    GUISwitch($GuiWindow)
    GUIDelete($GuiExit)
EndFunc

Thanks in advance for any help. :D

Share this post


Link to post
Share on other sites



I tried it.

When I want to exit, the child window pop up and it can't work correct.

I modify it , You can try this. :)

; Script Start
#include <GUIConstants.au3>
#Include <Misc.au3>
Opt("GUIOnEventMode", 1)
Opt("WinWaitDelay", 500)
Opt("SendKeyDelay", 20)
Opt("WinTitleMatchMode", 1)
$font = "Arial Bold"
Local $Count
Local $GuiExit

AutoItSetOption("TrayIconHide", 0) ;0 = show icon (default), 1 = hide icon.
Break(1) ;1 = Break is enabled (user can quit) (default), 0 = Break is disabled (user cannot quit).
WinMinimizeAll()
;Main Message Screen Text
$TextLine1 = "" & @CR & "Line1..."
$TextLine2 = "Software Title"
$TextLine3 = "Line3."
$TextLine4 = "Please note..." & @CR & "Line4."
$TextLine5 = 'Line5.'
$TextLine6 = "Line6A," & @CR & "Line6B." & @CR & "" & @CR & 'Click the "OK" button to begin installation or the "Exit" button to quit.'

;Main GUI Message Screen Creation
$GuiWindow = GUICreate("Attention!", 650, 430, -1, -1)
GUISetBkColor (0xCC99FF)
$GuiLine1 = GUICtrlCreateLabel($TextLine1, 0, 0, 650, 40, $SS_CENTER)
GUICtrlSetFont(-1, 12, 400, 0, $font)
GUICtrlSetColor ($GuiLine1, 0x000000)
$GuiLine2 = GUICtrlCreateLabel($TextLine2, 0, 45, 650, 25, $SS_CENTER)
GUICtrlSetFont(-1, 14, 400, 0, $font)
GUICtrlSetColor ($GuiLine2, 0xCC3300 )
$GuiLine3 = GUICtrlCreateLabel($TextLine3, 0, 75, 650, 60, $SS_CENTER)
GUICtrlSetFont(-1, 12, 400, 0, $font)
GUICtrlSetColor ($GuiLine3, 0x000000)
$GuiLine4 = GUICtrlCreateLabel($TextLine4, 0, 140, 650, 50, $SS_CENTER)
GUICtrlSetFont(-1, 14, 400, 0, $font)
GUICtrlSetColor ($GuiLine4, 0x000080 )
$GuiLine5 = GUICtrlCreateLabel($TextLine5, 0, 190, 650, 20, $SS_CENTER)
GUICtrlSetFont(-1, 12, 400, 0, $font)
GUICtrlSetColor ($GuiLine5, 0xFF0000)
$GuiLine6 = GUICtrlCreateLabel($TextLine6, 0, 250, 650, 130, $SS_CENTER)
GUICtrlSetFont(-1, 12, 400, 0, $font)
GUICtrlSetColor ($GuiLine6, 0x000000)
$Okbutton = GUICtrlCreateButton("OK", 235, 380, 80)
$ExitButton = GUICtrlCreateButton("Exit", 335, 380, 80)
$TestButton = GUICtrlCreateButton("Connection Test", 270, 218, 110)
GUICtrlSetOnEvent($ExitButton, "ExitClicked")
GUICtrlSetOnEvent($OKbutton, "OKClicked")
GUICtrlSetOnEvent($TestButton, "TestConnection")
GUISetOnEvent($GUI_EVENT_MINIMIZE, "Minimize")
GUISetOnEvent($GUI_EVENT_CLOSE, "ExitClicked")
GUISetState(@SW_SHOW)

While 1
    Sleep(1000)
WEnd

Exit

Func InstallProgram()
     ;For Testing purposes only.
     ;Run Program Install
     MsgBox(0,"Test", "Program install would run here!")
     Exit
EndFunc

Func TestConnection()
     SplashTextOn("Please wait...", @CR & "Testing in progress... ", 300, 80, -1, -1, 0, "", 14, 400)
     ; 0 = not connected, 1 is connected.
     $IsCon=DllCall("WinInet.dll","int","InternetGetConnectedState","int_ptr",0,"int",0)
     Sleep(1000)
     ;Ping failure...Ping returns 0, Success, Returns the roundtrip-time in milliseconds (greater than 0).
     $IPTest = Ping("172.31.1.11")
     SplashOff()
     If $IPTest > 0 Then 
    MsgBox(0,"Connection Test...", "Connected!" & @CR & "" & @CR & "You are connected to XXXXX's network." & @CR & "" & @CR & "Please click the OK button to start the install.")
    GUIDelete($GuiWindow)
     Else
    If $IsCon[0] = 0 Then
        MsgBox(0,"Connection Test...", "Error!" & @CR & "" & @CR & "You are NOT connected to XXXXX's network or the Internet." & @CR & "" & @CR & "Please connect to XXXXX's network and run this program again.")
    Else
        MsgBox(0,"Connection Test...", "Error!" & @CR & "" & @CR & "You are connected to the Internet, but NOT connected to XXXXX's network." & @CR & "" & @CR & "Please connect to XXXXX's network and run this program again.")
    EndIf
     EndIf
EndFunc

Func ExitClicked()
    ;GUISetState(@SW_HIDE, $GuiWindow)
    $GuiExit = GUICreate("Exit?", 420, 180, -1, -1, $DS_SETFOREGROUND,$WS_EX_TOPMOST)
    GUISetBkColor (0x000000)
    $ExitText = "Are you sure you want to cancel this installation?" & @CR & "" & @CR & "It's very important that you install this software!"
    $ExitMessage = GUICtrlCreateLabel($ExitText, 20, 20, 390, 75)
    GUICtrlSetColor ($ExitMessage, 0xff0000)
    GUICtrlSetFont(-1, 12, 400, 0, $font)
    $ExitYes = GUICtrlCreateButton("Yes", 100, 100, 100, 30)
    $ExitNo = GUICtrlCreateButton("No", 220, 100, 100, 30)
    GUICtrlSetOnEvent($ExitYes, "ExitYes")
    GUICtrlSetOnEvent($ExitNo, "ExitNo")
    GUISwitch($GuiExit)
    GUISetState(@SW_SHOW,$GuiExit)
    ;GUISetState()

    ;While 1
    ;    Sleep(100)
    ;WEnd
   
EndFunc   ;==>CLOSEClicked

Func Minimize()
    Sleep(60000)
    SoundPlay(@WindowsDir & "\media\Windows XP Balloon.wav",1)
    GUISetState(@SW_RESTORE)
    GUISetState()
EndFunc

Func OKClicked()
    GUICreate("", 400, 316, -1, -1, $WS_EX_TOPMOST)
    GUISetBkColor(0xFFFFFF)
    $GUIMainText = GUICtrlCreateLabel("Please type the following information: ", 20, 20, 350, 30)
    GUICtrlSetFont(-1, 14, 400, 0, $font)
    GUICtrlSetColor($GUIMainText, 0xFF0000)
    $LabelFirstName = GUICtrlCreateLabel("First Name:", 20, 70, 350, 20)
    GUICtrlSetFont(-1, 12, 400, 0, $font)
    $InputFirstName = GUICtrlCreateInput("", 20, 90, 350, 30)
    GUICtrlSetFont(-1, 12, 400, 0, $font)
    GUICtrlSetColor($InputFirstName, 0x0033FF)
    $LabelLastName = GUICtrlCreateLabel("Last Name:", 20, 140, 350, 20)
    GUICtrlSetFont(-1, 12, 400, 0, $font)
    $InputlastName = GUICtrlCreateInput("", 20, 160, 350, 30)
    GUICtrlSetFont(-1, 12, 400, 0, $font)
    GUICtrlSetColor($InputlastName, 0x0033FF)
    $OKButton6 = GUICtrlCreateButton("OK", 135, 225, 120, 30)
    GUICtrlSetOnEvent($OKButton6, "InstallProgram")
    GUICtrlSetState($OKButton6, $GUI_DISABLE)
    GUISetState()

    While 1
        Sleep(10)
        $TypedName = GUICtrlRead($InputlastName)
        If $TypedName <> "" And BitAND(GUICtrlGetState($OKButton6), $GUI_DISABLE) = $GUI_DISABLE Then
            GUICtrlSetState($OKButton6, $GUI_ENABLE)
        ElseIf $TypedName = "" And BitAND(GUICtrlGetState($OKButton6), $GUI_ENABLE) = $GUI_ENABLE Then
            GUICtrlSetState($OKButton6, $GUI_DISABLE)
        EndIf
    WEnd
EndFunc

Func ExitYes()
    ;FileDelete("C:\Software\HAT\........")
    ;FileDelete("C:\Software\HAT\......")
    ;FileDelete("C:\Software\HAT\......")
    ;Call ("SelfDelete")
    Exit
EndFunc

Func ExitNO()
    ;GUISetState(@SW_SHOW, $GuiWindow)
    GUISwitch($GuiWindow)
    GUIDelete($GuiExit)
EndFunc

Share this post


Link to post
Share on other sites

I tried it.

When I want to exit, the child window pop up and it can't work correct.

I modify it , You can try this. :)

Thank you soo much Edgar. :D

I can't beleive I didn't realize the added While/Wend loop... :D

Another lesson learned! :">

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  
Followers 0