NELyon Posted May 13, 2007 Posted May 13, 2007 I was experimenting with a wrapper for the function SetParent (from user32.dll) and i found a small problem with it. It doesn't seem to repaint the child window properly if the window is moved off of the parent. Heres an example i used with Notepad. #include <GUIConstants.au3> Run("notepad.exe") WinWait("Untitled - Notepad") #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("AForm1", 691, 515, 193, 123) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### DLLCall("user32.dll", "str", "SetParent", "hwnd", WinGetHandle("Untitled - Notepad"), "hwnd", WinGetHandle("AForm1")) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEndIt sets Notepad as the child, but if i move the notepad window off of the Parent GUI, and move it back, here's what happens:Anyone know whats going on?
NELyon Posted May 13, 2007 Author Posted May 13, 2007 Hmm... i wonder... would it work if i just sent a $WM_PAINT message to it in the While loop?
Noob Posted June 6, 2007 Posted June 6, 2007 (edited) I tried your code and I it really doesn't work properly. I don't know why, but since I also need the SetParent function, so I've played with it a little bit. The following code seems to work, but I do not think if this is the correct way to do it. I only added the line WinActivate($Form1) after the DLLCall. #include <GUIConstants.au3> Run("notepad.exe") WinWait("Untitled - Notepad") #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("AForm1", 691, 515, 193, 123) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### DLLCall("user32.dll", "str", "SetParent", "hwnd", WinGetHandle("Untitled - Notepad"), "hwnd", WinGetHandle("AForm1")) WinActivate($Form1) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Edited June 6, 2007 by Noob
ResNullius Posted June 29, 2007 Posted June 29, 2007 I was experimenting with a wrapper for the function SetParent (from user32.dll) and i found a small problem with it. It doesn't seem to repaint the child window properly if the window is moved off of the parent. Heres an example i used with Notepad.Senton-Bomb, don't know if you're still looking for a solution to this, but I did some testing with the code that lod3n posted here: http://www.autoitscript.com/forum/index.ph...st&p=365233 and the following solves the problem for me - #include <GUIConstants.au3> Run("notepad.exe") WinWait("Untitled - Notepad") #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("AForm1", 691, 515, 193, 123) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### DLLCall("user32.dll", "str", "SetParent", "hwnd", WinGetHandle("Untitled - Notepad"), "hwnd", WinGetHandle("AForm1")) $guiStyle = BitOR($WS_BORDER, $WS_CAPTION, $WS_CLIPCHILDREN, $WS_CLIPSIBLINGS, $WS_DLGFRAME, $WS_GROUP, $WS_MAXIMIZE, $WS_MAXIMIZEBOX, $WS_MINIMIZEBOX, $WS_SYSMENU, $WS_TABSTOP, $WS_THICKFRAME, $WS_VISIBLE) ; 0x17CF0100 $guiStyleEx = $WS_EX_WINDOWEDGE ; 0x00000100 _SetStyle($Form1,$guiStyle,$guiStyleEx) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func _SetStyle($hwnd,$style,$exstyle) DllCall("user32.dll", "long", "SetWindowLong", "hwnd", $hwnd, "int", -16, "long", $style) DllCall("user32.dll", "long", "SetWindowLong", "hwnd", $hwnd, "int", -20, "long", $exstyle) EndFunc
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