qwert Posted July 30, 2014 Share Posted July 30, 2014 I have a GUI that consists of a PNG “backdrop” image, created with: $mainGUI = GUICreate("Control", $cWidth, $cHeight, $cX, $cY, $WS_POPUP, BitOR($WS_EX_TOPMOST, $WS_EX_LAYERED, $WS_EX_TOOLWINDOW)) SetBitmap($cGUI, $cImage, 255) GUICtrlSetState($cGUI, $GUI_DISABLE) . Then, to get “full effect buttons” (i.e., with theme colors, mouseover effects, etc.) on top of the image, I create a child window using: $buttonGUI = GUICreate("", $width, $height, 0, 0, $WS_POPUP, BitOR($WS_EX_MDICHILD, $WS_EX_LAYERED), $mainGUI) $sampleButton = GUICtrlCreateButton("Button", 100, 60, 70, 24) . 99% of the time, my WinMove($mainGUI) calls move everything together as a unit (parent+child). But, occasionally—especially after Win8 recovers from Sleep Mode—the coordinates of the child elements become disassociated from the parent GUI. The buttons, for example, do move when the parent window is moved, but they have their own set of coordinates ... usually off to the left of the parent GUI by three or four hundred pixels. So, if have these questions: Is there a surefire way to bind child windows to the parent? Also, is there a better way to display buttons on the parent GUI? IOW, other than creating a child window to hold them. When I place them directly on the parent GUI, they operate, but they’re not visible. Thanks in advance for any help. Link to comment Share on other sites More sharing options...
qwert Posted August 1, 2014 Author Share Posted August 1, 2014 In my continuing search for a solution, I found the following point in a reader comment on an msdn page: SetWindowPlacement(...) should be used by application whenever they wish to restore a window to a previous persisted state. This is because this function will correct inaccurate coordinates. The net result is that applications and their windows can avoid being obscured by changes in the taskbar or other non-workspace areas of the display. SetWindowPos, for example, will not protect against this. My interpretation is that this approach would require full monitoring of the child window using a style structure (using DllStructCreate and _WinAPI_GetWindowPlacement). But, before I dive into that unfamiliar territory, I'd like to ask: 1. Does this sound correct? 2. Is there a simpler alternative that would cause the WinMove() statements to work properly? Link to comment Share on other sites More sharing options...
MikahS Posted August 4, 2014 Share Posted August 4, 2014 (edited) Let windows do it for you with the: _WinAPI_SetParent($buttonGUI, $mainGUI) That should let you move both with one: WinMove call to the main GUI. EDIT: edited solution Edited August 4, 2014 by MikahS Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ Link to comment Share on other sites More sharing options...
qwert Posted August 5, 2014 Author Share Posted August 5, 2014 Thanks for your response. At this point, I'm willing to try anything. But how is this different from the parent/child relation specified when the child GUI is created? Link to comment Share on other sites More sharing options...
MikahS Posted August 5, 2014 Share Posted August 5, 2014 It uses Windows to make the parent - child association. Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ 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