Sign in to follow this  
Followers 0
jfcby

Child GUI Want Reopen [Resolved]

2 posts in this topic

#1 ·  Posted (edited)

Hi,

I'm trying to modify a script that I found in this forum. When I try to run the child gui for a second time it will not show. Why want the child gui show when I try to run it for the second time?

#include <GuiConstantsEx.au3>
#include <EditConstants.au3>
#include <GuiEdit.au3>
#include <WindowsConstants.au3>
#include <array.au3>
#include <GuiListBox.au3>
#include <StaticConstants.au3>


Global $msg

$hWidth = 395
$hHeight = 425
$hLeft = $hWidth / 2
$hTop = $hHeight / 2
$hGUI = GUICreate("Main GUI", $hWidth, $hHeight, (@DesktopWidth / 2) - $hLeft, (@DesktopHeight / 2) - $hTop)

    $Label1 = GUICtrlCreateLabel("Label 1", 5, 1, 100, 15)
    GUICtrlSetFont(-1, 9, 600)  
    
    $Edit1 = GUICtrlCreateEdit("Edit control.", 5, 25, 385, 350, _
        BitOR($ES_AUTOVSCROLL, $ES_MULTILINE, $ES_NOHIDESEL, $ES_WANTRETURN))
    
    $Button1 = GUICtrlCreateButton("Run cGUI", 325, 380)    
    
GUISetState(@SW_SHOW)

;Create ChildGUI & Center in Main GUI:  parent width/2 minus the child's width/2
$cWidth = 250
$cHeight = 250              
$cLeft = $hWidth / 2 - $cWidth / 2
$cTop = $hHeight /2 - $cHeight / 2
$cGUI = GUICreate("Child GUI", $cWidth, $cHeight, $cLeft, $cTop, Default, BitOR($WS_EX_MDICHILD, $WS_EX_TOOLWINDOW), $hGUI)
    $cLabel1 = GUICtrlCreateLabel("cLabel 1", 5, 5, 75, 20)
    $cLabel2 = GUICtrlCreateLabel("cLabel 2", 5, 30, 75, 20)    
    $cInput1 = GUICtrlCreateInput("cInput 1", 100, 5, 145, 20)
    GUICtrlSetState(-1, $GUI_DISABLE)   ; the label is in disable state
    $cInput2 = GUICtrlCreateInput("cInput 2", 100, 30, 145, 20)
    $cListBox1 = GUICtrlCreateList("cListbox 1", 5, 55, 155, 200)
    $cButton1 = GUICtrlCreateButton("cButton 1", 170, 65, 75, 20)
    $cButton2 = GUICtrlCreateButton("cButton 2", 170, 85, 75, 20)   
    $cButton3 = GUICtrlCreateButton("cButton 3", 170, 225, 75, 20)
GUISetState(@SW_HIDE)

While 1
    $Msg = GUIGetMsg()
    Select
        Case $Msg = $GUI_EVENT_CLOSE
            Exit        
        Case $Msg = $Button1
            ; Show the child            
            GUISetState(@SW_SHOW, $cGUI)            
            While 1
                $aMsg = GUIGetMsg(1)
                If $aMsg[1] = $cGUI Then ; Check we are getting messages from the child
                    Switch $aMsg[0]
                        Case $GUI_EVENT_CLOSE, $cButton3
                            GUIDelete($cGUI)
                            ExitLoop
                        Case $cButton1      ; Replace                           
                            MsgBox(0, "Debug:", "Button Replace!")
                        Case $cButton2      ; Ignore
                            MsgBox(0, "Debug:", "Button Ignore!")
                    EndSwitch
                EndIf
            WEnd
    EndSelect
WEnd

Thank you for your help,

jfcby

Edited by jfcby

Determined -- Devoted -- Delivered Make your mind up -- to seriously apply yourself -- accomplishing the desired results. **** A soft answer turneth away wrath: but grievous words stir up anger. Proverbs 15:1 KJB ****

Share this post


Link to post
Share on other sites



jfcby,

Perhaps if you just hid the child when you exited, rather than deleting it? :D

Case $GUI_EVENT_CLOSE, $cButton3
    GUISetState(@SW_HIDE, $cGUI); GUIDelete($cGUI)  ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    ExitLoop

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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