Mungo Posted May 21, 2010 Share Posted May 21, 2010 (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 May 21, 2010 by Mungo Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted May 21, 2010 Moderators Share Posted May 21, 2010 (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 May 21, 2010 by SmOke_N Clarity 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. Link to comment Share on other sites More sharing options...
Mungo Posted May 22, 2010 Author Share Posted May 22, 2010 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 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now