Zaxon Posted April 26, 2005 Share Posted April 26, 2005 I'm wanting to place alot of my code into libraries. However, I'm finding that certain functionality, like closing or minimizing a window, doesn't necessarily work this way. Consider the following test example: #include <GUIConstants.au3> opt ("GUIOnEventMode", 1) $parenth=GUICreate("parent") GUISetOnEvent($GUI_EVENT_CLOSE, "minimize_me_generic") GUISetState() GUICreate("child",100,100) GUISetOnEvent($gui_event_close, "minimize_me_specific") GUISetState() func minimize_me_generic() GUISetState(@SW_MINIMIZE) endfunc func minimize_me_specific() GUISetState(@SW_MINIMIZE) guiswitch($parenth) endfunc sleep(20000) When you run the script, a parent and then a child window is created. Click on the close button of the child window, and then on the close button of the parent window. Both windows minimize, as is the intention of this script. However, the child window has to also call make a specific guiswitch by name. It cannot call a generic "minimize me" routine. To see this, comment out the guiswitch() to make both minimize functions identical. Run it again. Does it work now? What you'll find is the child window will minimize, but the parent window has lost the close event association. How can I write a generic minimize window function that doesn't need to know by name who its parent is? Link to comment Share on other sites More sharing options...
MHz Posted April 26, 2005 Share Posted April 26, 2005 To use a parent / child windows, you need to use the parameter that enables it. GUICreate ( "title" [, width [, height [, left [, top [, style [, exStyle [, parent]]]]]]] ) parent -> [optional] The handle of another previously created window - this new window then becomes a child of that window. Link to comment Share on other sites More sharing options...
Zaxon Posted April 26, 2005 Author Share Posted April 26, 2005 To use a parent / child windows, you need to use the parameter that enables it.GUICreate ( "title" [, width [, height [, left [, top [, style [, exStyle [, parent]]]]]]] ) parent -> [optional] The handle of another previously created window - this new window then becomes a child of that window.<{POST_SNAPBACK}>I see. I've made that addition expectantly, but the result hasn't changed. The parent window still doesn't automatically become the current window.#include <GUIConstants.au3> opt ("GUIOnEventMode", 1) $parenth=GUICreate("parent") GUISetOnEvent($GUI_EVENT_CLOSE, "minimize_me_generic") GUISetState() GUICreate("child",100,100,-1,-1,-1,-1,$parenth) GUISetOnEvent($gui_event_close, "minimize_me_specific") GUISetState() func minimize_me_generic() GUISetState(@SW_MINIMIZE) endfunc func minimize_me_specific() GUISetState(@SW_MINIMIZE) ;guiswitch($parenth) endfunc sleep(20000) Link to comment Share on other sites More sharing options...
quaizywabbit Posted April 26, 2005 Share Posted April 26, 2005 (edited) GUISetState ( [flag [, winhandle]] ) in your minimize specific function, try including the winhandle in GuiSetState() also: $GUI_EVENT_CLOSE $gui_event_close why are these different? Edited April 26, 2005 by quaizywabbit [u]Do more with pre-existing apps![/u]ANYGUIv2.8 Link to comment Share on other sites More sharing options...
Zaxon Posted April 26, 2005 Author Share Posted April 26, 2005 GUISetState ( [flag [, winhandle]] )in your minimize specific function, try including the winhandle in GuiSetState()also:$GUI_EVENT_CLOSE$gui_event_closewhy are these different?<{POST_SNAPBACK}>Gui constants aren't case specific, so $GUI_EVENT_CLOSE and $gui_event_close are both identical. If if they hadn't been, then the minimize_me_specific() wouldn't have been called. But it is, and it works if you include the GuiSwitch line.But the winhandle parameter has done the trick! I've been able to use that technology to create a generic minimize function. Thanks for the help. Link to comment Share on other sites More sharing options...
jpm Posted April 26, 2005 Share Posted April 26, 2005 I see. I've made that addition expectantly, but the result hasn't changed. The parent window still doesn't automatically become the current window.#include <GUIConstants.au3> opt ("GUIOnEventMode", 1) $parenth=GUICreate("parent") GUISetOnEvent($GUI_EVENT_CLOSE, "minimize_me_generic") GUISetState() GUICreate("child",100,100,-1,-1,-1,-1,$parenth) GUISetOnEvent($gui_event_close, "minimize_me_specific") GUISetState() func minimize_me_generic() GUISetState(@SW_MINIMIZE) endfunc func minimize_me_specific() GUISetState(@SW_MINIMIZE) ;guiswitch($parenth) endfunc sleep(20000)<{POST_SNAPBACK}>if you want to do action on a specific window you need to define itas i undertsnad your code you needfunc minimize_me_generic() GUISetState(@SW_MINIMIZE,$parenth) endfunc@quaizywabbit$GUI_EVENT_CLOSE = $gui_event_close AutoIT3 is not case sensitive for variable names 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