Sign in to follow this  
Followers 0
Mungo

How to get the GUI id of previous (parent?) GUI window

3 posts in this topic

#1 ·  Posted (edited)

Might be simple but I am struggling ... and sorry for my probably very unprofessional explanation attempt ....

I have a program with several also cascading windows and if I close one the previous is shown/active again as to GUISetState(@SW_SHOW, $parent1). This is simple as I know the ID of the previous (e.g. parent1) GUI.

However, I want to add a pop-up GUI in a function so that I can call it from various GUI windows and levels. However, if the GUI (in the function) closes I want that window to be shown which called the pop up window. How to know which window called it?

I tried to get the handle of the previous window using _WinAPI_GetAncestor($hWnd, $GA_PARENT) as to the example.

$hwnd = GUICreate("pop up")
$hparent = _WinAPI_GetAncestor($hwnd, $GA_PARENT)
....
GUIDelete()
GUISetState(@SW_SHOW, $hparent)

.... does not work - I guess I got something conceptional wrong here ... ? Any help?

Thanks!

Edited by Mungo

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Might be simple but I am struggling ... and sorry for my probably very unprofessional explanation attempt ....

I have a program with several also cascading windows and if I close one the previous is shown/active again as to GUISetState(@SW_SHOW, $parent1). This is simple as I know the ID of the previous (e.g. parent1) GUI.

However, I want to add a pop-up GUI in a function so that I can call it from various GUI windows and levels. However, if the GUI (in the function) closes I want that window to be shown which called the pop up window. How to know which window called it?

I tried to get the handle of the previous window using _WinAPI_GetAncestor($hWnd, $GA_PARENT) as to the example.

$hwnd = GUICreate("pop up")
$hparent = _WinAPI_GetAncestor($hwnd, $GA_PARENT)
....
GUIDelete()
GUISetState(@SW_SHOW, $hparent)

.... does not work - I guess I got something conceptional wrong here ... ? Any help?

Thanks!

The GUI actually has to have a parent to get the parent hwnd ( With an AutoIt GUI, this is set in the last param of GUICreate()). With your example, it does not.

If you're looking for the parent only and not the root, you could use _WinAPI_GetParent() as well, but with your example, the result would be the same.

Edited by SmOke_N
Clarity

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

The GUI actually has to have a parent to get the parent hwnd ( With an AutoIt GUI, this is set in the last param of GUICreate()). With your example, it does not.

If you're looking for the parent only and not the root, you could use _WinAPI_GetParent() as well, but with your example, the result would be the same.

Thanks for the explanation, I think I got the idea now.

I always assumed that there would be a (simple) way to always detect the handle of the parent window without actually directly 'telling' the child window from which parent it came from. In my case, as the new GUI is inside a function which is called from various windows, this is not possible.

The work around for me is that I simply remove the line

GUISetState(@SW_SHOW, $gui_parent_x)

from the function and add it after the function call in the Message Loop call.

Cheers

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