Jump to content

Child GUI of a child GUI closing program


dinodod
 Share

Recommended Posts

I am not seeing what I can do to prevent my child GUI from closing down the entire application rather than itself. The Child GUI works but when I click on the X, it closes down the entire application rather than itself. This is possible, right?

Sample code:

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

$ChildGUI_ManagePrinters = GUICreate("Manage Printers", $ChildGUI_Printers_Width, $ChildGUI_Printers_Height, $ChildGUI_Printers_X, $ChildGUI_Printers_Y, _

Bitor($WS_CHILD, $WS_POPUPwindow, $WS_CAPTION , $WS_SYSMENU, $WS_BORDER), $MainGUI)

Even making it it's own GUI doesn't work

$ChildGUI_ManagePrinters = GUICreate("Manage Printers", $ChildGUI_Printers_Width, $ChildGUI_Printers_Height, $ChildGUI_Printers_X, $ChildGUI_Printers_Y)

Thanks

Edited by dinodod

Digital Chaos - Life as we know it today.I'm a Think Tank. Problem is, my tank is empty.The Quieter you are, the more you can HearWhich would you choose - Peace without Freedom or Freedom without Peace?Digital Chaos Macgyver ToolkitCompletely Dynamic MenuSQLIte controlsAD FunctionsEXCEL UDFPC / Software Inventory UDFPC / Software Inventory 2GaFrost's Admin Toolkit - My main competitor :)Virtual SystemsVMWAREMicrosoft Virtual PC 2007

Link to comment
Share on other sites

Are you exiting on $GUI_CLOSE_EVENT in your child? If so, You might try GuiSwitch( ) to parent then GuiDelete() the child.

eltorro

Link to comment
Share on other sites

Not in the child gui portion.

However, I do have the following to look for what the user is clicking on. The question is, is there a way to make the 'x' button on a childGUI return a different value than the parent GUI 'x' button? I have to think about this one. I see where I need to tuck the $msg = $GUI_EVENT_CLOSE inside the loop and then test it for what window is trying to get closed. Off the top of my head, I'm thinking I need to be able to retrieve the GUI title and test it that way to see if my main GUI is trying to close or not.

I'll give it a shot. Thanks for the advise! If you have any other thoughts, please let me know.

GUISetState ()

Do

$msg = GUIGetMsg()

Select

Case xxx

Case yyy

EndSelect

Until $msg = $GUI_EVENT_CLOSE

msgbox(0,"","exiting")

Digital Chaos - Life as we know it today.I'm a Think Tank. Problem is, my tank is empty.The Quieter you are, the more you can HearWhich would you choose - Peace without Freedom or Freedom without Peace?Digital Chaos Macgyver ToolkitCompletely Dynamic MenuSQLIte controlsAD FunctionsEXCEL UDFPC / Software Inventory UDFPC / Software Inventory 2GaFrost's Admin Toolkit - My main competitor :)Virtual SystemsVMWAREMicrosoft Virtual PC 2007

Link to comment
Share on other sites

:) GENIUS!

Case $msg = $GUI_EVENT_CLOSE

If WinActive("Manage Printers") Then

MsgBox(0, "", "Window was active")

GUISetState(@SW_Hide, $ChildGUI_ManagePrinters )

EndIf

Now I just have to make sure to put Titles everywhere in my GUI's!

GUIDELETE won't work since it destroys the gui and all controls inside. If I need to re-open the GUI, it doesn't work. Hiding the GUI does :D

Thanks for poitning me in the right direction. AUTOIT is better than BASIC :D

Digital Chaos - Life as we know it today.I'm a Think Tank. Problem is, my tank is empty.The Quieter you are, the more you can HearWhich would you choose - Peace without Freedom or Freedom without Peace?Digital Chaos Macgyver ToolkitCompletely Dynamic MenuSQLIte controlsAD FunctionsEXCEL UDFPC / Software Inventory UDFPC / Software Inventory 2GaFrost's Admin Toolkit - My main competitor :)Virtual SystemsVMWAREMicrosoft Virtual PC 2007

Link to comment
Share on other sites

  • 1 month later...

:whistle: GENIUS!

Case $msg = $GUI_EVENT_CLOSE

If WinActive("Manage Printers") Then

MsgBox(0, "", "Window was active")

GUISetState(@SW_Hide, $ChildGUI_ManagePrinters )

EndIf

Now I just have to make sure to put Titles everywhere in my GUI's!

GUIDELETE won't work since it destroys the gui and all controls inside. If I need to re-open the GUI, it doesn't work. Hiding the GUI does :)

Thanks for poitning me in the right direction. AUTOIT is better than BASIC :lol:

You should still be able to use GUIDELETE to kill the child gui. You just need to use the handle of the window. If it was $CHILDGUI then it would be GUIDELETE($CHILDGUI). You shouldn't have to hide it. Also if you wanted to use it again you could probably put it in a function to call your child gui. Not sure exactly what you want to do and I'm not a AutoIT guru but I have done similar. Here is a window in window script I wrote up for another post it might help you as well.

#include <GUIConstants.au3>

dim $Var1_CHKBOX
dim $RUN
dim $EXIT
dim $VarStatus1
Dim $GUINAME = "Main Window"
Dim $GUINAME2 = "Another Window"
GUICreate ($GUINAME,300,450)
GUISetFont(14,600)
GUICtrlCreateLabel($GUINAME,90,80)
GUISetFont(9,400)
$Var1_CHKBOX = GUICtrlCreateCheckbox("Some function to run",10,130)  ;Checkbox 1
$RUN = GUICtrlCreateButton("Run",10,350,120,20)  ;This is the Run button
$EXIT = GUICtrlCreateButton("Exit",168,350,120,20)  ;This is to exit the application
$OpenGUI2 = GUICtrlCreateButton("GUI 2",85,390,120,20)  ;This is the Run button
GUISetState()

CAll("Main")

Func Main()
While 1
     $msg = GUIGetMsg()
     $VarStatus1 = GUICtrlRead($Var1_CHKBOX)
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        Case $msg = $EXIT
            Exit
        Case $msg = $RUN            
            If $VarStatus1 = 1 Then Call("ITEM_1")
        Case $msg = $OpenGUI2
            Call("New_Gui")
        EndSelect
WEnd
EndFunc
     
Func New_Gui()
    GUICreate ($GUINAME2,300,450)    
    GUISetFont(14,600)
    GUICtrlCreateLabel($GUINAME2,70,80)
    GUISetFont(9,400)
    $GUI2Var1_CHKBOX = GUICtrlCreateCheckbox("Another function to run",10,130)  ;Checkbox 1
    $RUN2 = GUICtrlCreateButton("Run",10,350,120,20)  ;This is the Run button
    $EXIT2 = GUICtrlCreateButton("Exit",168,350,120,20)  ;This is to exit the application
    GUISetState()
    
    While 1
        $msg = GUIGetMsg()
        $GUI2VarStatus1 = GUICtrlRead($GUI2Var1_CHKBOX)
    Select
        Case $msg = $GUI_EVENT_CLOSE or $msg = $EXIT2
            GUIDelete($GUINAME2)
            CAll("Main")
        Case $msg = $RUN2
            If $GUI2VarStatus1 = 1 Then Call("GUI2ITEM_1")
        EndSelect
WEnd
    EndFunc
;The list of functions to run from either GUI
Func ITEM_1()
    MsgBox(64, $GUINAME, "Some function to run.", 10)
EndFunc

Func GUI2ITEM_1()
    MsgBox(64, $GUINAME2, "Another function to run on GUI 2.", 10)
EndFunc
EndFuncAutoIt is the shiznit. I love it.
Link to comment
Share on other sites

#include <GUIConstants.au3>

$gui=GUICreate("Parent", 800, 300)
$button=GUICtrlCreateButton("test",10,10,100,15)
GUISetState(@SW_SHOW)

do
  $msg = GUIGetMsg()
  Select
    Case $msg = $button
        $guichild=GUICreate("Child", 800, 300,10,10)
      GUISetState(@SW_SHOW,$guichild)
          do
        $childmsg = GUIGetMsg(1)
            if not WinActive($guichild) and Winactive($gui) Then winactivate($guichild)
                
      until $childmsg[0]    = $GUI_EVENT_CLOSE and $childmsg[1] = $guichild 
          GUIDelete($guichild)
    EndSelect

until $msg = $GUI_EVENT_CLOSE

Just use the extended information of the GUIGetmsg

This example also gives focus back to the child window

Dont cry tomorrow about what you should have done yesterday. Just do it now.

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