Jump to content

GUI breaks when Child GUI closes.


Recommended Posts

This post has 2 issues. (Yes I know this is a very basic looking GUI setup.)

1:  When I close the child GUI, the parent GUI breaks. ( I dont want the parent GUI to close. This is supposed to be an end user kiosk terminal.)

2: The Conference Phone checkbox isn't working like the others, even though they are set up the exact same way.

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>


#Region ### START Koda GUI section ### Form=
Global $Form1 = GUICreate("Form1", 1921, 1080)
GUICtrlSetResizing(-1, 1)
GUICtrlSetBkColor(-1, 0xFFFFFF)

Global $Button1 = GUICtrlCreateButton("SIGN OUT", 203, 364, 731, 289)
GUICtrlSetFont(-1, 100, 800, 0, "@Microsoft YaHei")
GUICtrlSetBkColor(-1, 0x00FF00)
Global $Button2 = GUICtrlCreateButton("SIGN IN", 987, 364, 731, 289)
GUICtrlSetFont(-1, 100, 800, 0, "@Microsoft YaHei")
GUICtrlSetBkColor(-1, 0xFF0000)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg

        Case $Button1
            #Region ### START Koda GUI section ### Form=
            Global $Form2 = GUICreate("Form2", 1920, 1080)
            GUICtrlSetResizing(-1, 1)
            GUICtrlSetBkColor(-1, 0xFFFFFF)

            Global $Name = GUICtrlCreateLabel("Name", 150, 100, 196, 92)
            GUICtrlSetFont(-1, 30, 400, 0, "@Microsoft YaHei")

            Global $Dept = GUICtrlCreateLabel("Department", 150, 200, 230, 92)
            GUICtrlSetFont(-1, 30, 400, 0, "@Microsoft YaHei")

            Global $AVLaptop1 = GUICtrlCreateLabel("AV Laptop 1", 1000, 100, 400, 92)
            GUICtrlSetFont(-1, 30, 400, 0, "@Microsoft YaHei")

            Global $AVLaptop2 = GUICtrlCreateLabel("AV Laptop 2", 1000, 200, 400, 92)
            GUICtrlSetFont(-1, 30, 400, 0, "@Microsoft YaHei")

            Global $cPhone = GUICtrlCreateLabel("Confrence Phone", 1000, 300, 557, 92)
            GUICtrlSetFont(-1, 30, 400, 0, "@Microsoft YaHei")

            Global $Projector = GUICtrlCreateLabel("Projector", 1000, 400, 298, 92)
            GUICtrlSetFont(-1, 30, 400, 0, "@Microsoft YaHei")

            Global $Input1 = GUICtrlCreateInput("", 300, 100, 500, 60)
            GUICtrlSetFont(-1, 30, 900, 0, "@Microsoft YaHei")

            Global $Checkbox1 = GUICtrlCreateLabel("", 1400, 100, 80, 90, 0x1201)
            GUICtrlSetFont(-1, 75, 900, 0, "@Microsoft YaHei")
            GUICtrlSetBkColor(-1, 0xFFFFFF)

            Global $Checkbox2 = GUICtrlCreateLabel("", 1400, 200, 80, 90, 0x1201)
            GUICtrlSetFont(-1, 75, 900, 0, "@Microsoft YaHei")
            GUICtrlSetBkColor(-1, 0xFFFFFF)

            Global $Checkbox3 = GUICtrlCreateLabel("", 1400, 300, 80, 90, 0x1201)
            GUICtrlSetFont(-1, 75, 900, 0, "@Microsoft YaHei")
            GUICtrlSetBkColor(-1, 0xFFFFFF)

            Global $Checkbox4 = GUICtrlCreateLabel("", 1400, 400, 80, 90, 0x1201)
            GUICtrlSetFont(-1, 75, 900, 0, "@Microsoft YaHei")
            GUICtrlSetBkColor(-1, 0xFFFFFF)

            Global $Confirm = GUICtrlCreateButton("Confirm", 1256, 816, 291, 137)
            GUICtrlSetFont(-1, 48, 800, 0, "@Microsoft YaHei")
            GUICtrlSetBkColor(-1, 0x00FF00)

            Global $OutHome = GUICtrlCreateButton("Home", 1552, 816, 291, 137)
            GUICtrlSetFont(-1, 48, 800, 0, "@Microsoft YaHei")
            GUICtrlSetBkColor(-1, 0xFF0000)

            GUISetState(@SW_SHOW)
            #EndRegion ### END Koda GUI section ###

            While 1
                $nMsg = GUIGetMsg()
                Switch $nMsg
                    Case $Checkbox1
                        Switch GUICtrlRead($Checkbox1)
                            Case ""
                                GUICtrlSetData($Checkbox1, "X")
                            Case Else
                                GUICtrlSetData($Checkbox1, "")
                        EndSwitch

                    Case $Checkbox2
                        Switch GUICtrlRead($Checkbox2)
                            Case ""
                                GUICtrlSetData($Checkbox2, "X")
                            Case Else
                                GUICtrlSetData($Checkbox2, "")
                        EndSwitch

                    Case $Checkbox3
                        Switch GUICtrlRead($Checkbox3)
                            Case ""
                                GUICtrlSetData($Checkbox3, "X")
                            Case Else
                                GUICtrlSetData($Checkbox3, "")
                        EndSwitch

                    Case $Checkbox4
                        Switch GUICtrlRead($Checkbox4)
                            Case ""
                                GUICtrlSetData($Checkbox4, "X")
                            Case Else
                                GUICtrlSetData($Checkbox4, "")
                        EndSwitch

                    Case $Confirm
                        Global $File = FileOpen(@DesktopDir & "\Test Input File.txt", 1)
                        FileWrite($File, GUICtrlRead($Input1) & ", " & GUICtrlRead($Checkbox1) & ", " & GUICtrlRead($Checkbox2) & ", " & GUICtrlRead($Checkbox3) & ", " & GUICtrlRead($Checkbox4) & ", " & @CRLF)
                        FileClose($File)
                        GUIDelete($Form2)
                        ExitLoop

                    Case $OutHome
                        GUIDelete($Form2)
                        ExitLoop



                EndSwitch
            WEnd


        Case $Button2


        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

 

Edited by Spikemg1
Link to comment
Share on other sites

9 minutes ago, Nine said:

no I mean exitloop of the child.  if you dont it will continue forever...

ok fixed thanks forgot to put ($Form1) after GUIDelete

Case $Confirm
                        Global $File = FileOpen(@DesktopDir & "\Test Input File.txt", 1)
                        FileWrite($File, GUICtrlRead($Input1) & ", " & GUICtrlRead($Checkbox1) & ", " & GUICtrlRead($Checkbox2) & ", " & GUICtrlRead($Checkbox3) & ", " & GUICtrlRead($Checkbox4) & ", " & @CRLF)
                        FileClose($File)
                        GUIDelete($Form1)
                        ExitLoop

                    Case $OutHome
                        GUIDelete($Form1)
                        ExitLoop

 

Edited by Spikemg1
Link to comment
Share on other sites

Link to comment
Share on other sites

But you dont need to check the box yourself, gui will do that for you, all you need to do is to $ischeck 1 = (GUICtrlRead ($checkbox1) = $GUI_CHECKED) 

$ischeck1 will true if checked and false otherwise

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