Page 1 of 1

How to identify the current GUI default window?

Posted: 08 Apr 2019, 05:41
by afe
Hello,

When the child GUI window is destroyed, which one is the current default window?

In the following example, when the Close button of the child window is clicked, the child window is destroyed, but at this time, the parent window GUI1 does not seem to be the default window.

Then, after the ButtonClose subroutine is executed, will GUI1 become the default window, or will GUI1 become the default window only after the GUI1 window is activated (such as clicking)?


Code: Select all

Gui, Add, Text, w200 vGui_1
Gui, Add, Button, x0, Open
Gui, Show, h100 w200
return

ButtonOpen:
Gui, 1:+Disabled
Gui, 2:Default
Gui, +Owner1
Gui, Add, Button,, Close
Gui, Show, h50 w100
return

2ButtonClose:
Gui, 1:-Disabled
Gui, 2:Destroy
; Gui, 1:Default
GuiControl, Text, Gui_1, TEST
return

Re: How to identify the current GUI default window?

Posted: 08 Apr 2019, 11:33
by lvalkov
Gui Destroy does not alter defaultness in any way, shape or form. It merely deletes the specified GUI. To find out what the default GUI for a given thread is, inspect A_DefaultGui. It will be 2 in your case, since Gui, 2:Default is the last instruction that changed it and given that your first button subroutine lacks a Return statement, the next subroutine immediately beneath it is executed. I am not even sure whether this is how you originally intended the code to flow. Regardless, the default GUI for the subroutine 2ButtonClose:, had you clicked the button, would have been 2 anyway, since clicking it internally sets the button thread's default GUI to the GUI containing the button.

Re: How to identify the current GUI default window?

Posted: 08 Apr 2019, 13:31
by afe
Due to negligence, I dropped the return and I have added it.

This means that even though GUI2 has been destroyed, it is still the default window.

After GUI2 is destroyed, GUI1 will not become the default window until the mouse clicks on the GUI1 window.

Is this correct?

Re: How to identify the current GUI default window?  Topic is solved

Posted: 09 Apr 2019, 14:22
by lvalkov
No. Clicking on the GUI1 window doesn't affect which GUI is the default one. Unless, of course, you're talking about clicking the button labeled "Close", belonging to GUI1, in which case, yes, the default GUI for the "Close" button thread will be set to GUI1. I've already explained this interaction in my previous post.

Re: How to identify the current GUI default window?

Posted: 04 Jul 2019, 12:24
by afe
Thank you very much for your explanation, now I finally understand.