Tomb Posted November 25, 2008 Share Posted November 25, 2008 (edited) How can i get the position of a child window which was made a child window with DllCall("user32.dll", "hwnd", "SetParent", "hwnd", $CHILD, "hwnd", $GUI)ControlGetPos - does not workWinGetPos - also does not work Edited November 25, 2008 by Tomb Link to comment Share on other sites More sharing options...
Tomb Posted November 25, 2008 Author Share Posted November 25, 2008 im still looking for a solution. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted November 25, 2008 Moderators Share Posted November 25, 2008 (edited) Try: Opt("WinSearchChildren", 1) before you use WinGetPos($CHILD) Edit: Keep in mind, $CHILD has to be a hwnd. Edited November 25, 2008 by SmOke_N 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...
Tomb Posted November 26, 2008 Author Share Posted November 26, 2008 i gave it a try. this is the test i used. but it doesnt seem to work correctly. #Include <GUIConstants.au3> #Include <WindowsConstants.au3> $Parent = GUICreate("parent window", 300, 300, -1, -1, BitOr($GUI_SS_DEFAULT_GUI,$WS_CLIPCHILDREN,$WS_EX_LAYERED), -1) GUISetOnEvent($GUI_EVENT_CLOSE, "ExitScript") Opt("WinSearchChildren", 1) Opt("GUIOnEventMode",1) GuiSetState(@SW_SHOW, $Parent) $Child = GUICreate("child window", 200, 200) $Button = GUICtrlCreateButton("push the button", 50, 50, 50, 50) GUICtrlSetOnEvent(-1, "Button") GUISetState(@SW_SHOW, $Child) DllCall("user32.dll", "hwnd", "SetParent", "hwnd", $Child, "hwnd", $Parent) ControlMove("", "", $Child, 0, 0, 200, 200) While 1 sleep(10) WEnd Func Button() $CPOS = ControlGetPos("", "", $Child) MsgBox(0, "", $CPOS[0] & " , " & $CPOS[1] & " , " & $CPOS[2] & " , " & $CPOS[3]) EndFunc Func ExitScript() Exit EndFunc Link to comment Share on other sites More sharing options...
Tomb Posted November 26, 2008 Author Share Posted November 26, 2008 (edited) hmm i just noticed that i was still using CotrolGetPos().going to try WinGetPos() with the Opt("WinSearchChildren", 1)edit:it seems that WinGetPos with Opt("WinSearchChildren", 1) works correctly.however, most of the child GUI's i am checking position of do not have a window title.if only there were a similar function to WinGetPos that could use control Id as a perameter.edit 2:now im looking at _WinAPI_GetClientRect but not entirely sure if it will work. Edited November 26, 2008 by Tomb Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted November 26, 2008 Moderators Share Posted November 26, 2008 (edited) hmm i just noticed that i was still using CotrolGetPos(). going to try WinGetPos() with the Opt("WinSearchChildren", 1) edit: it seems that WinGetPos with Opt("WinSearchChildren", 1) works correctly. however, most of the child GUI's i am checking position of do not have a window title. if only there were a similar function to WinGetPos that could use control Id as a perameter. edit 2: now im looking at _WinAPI_GetClientRect but not entirely sure if it will work.I don't really see your issue here. GUICreate() returns a handle. So ControlGetPos() if it is a child, using the parents handle as the first param should work fine. I have no clue why you are leaving the first parameter blank of ControlGetPos(). At any rate. Func _Win_GetChildPos($h_parent, $h_child) Local $h_wnd = ControlGetHandle($h_parent, "", $h_child) Return WinGetPos($h_wnd) EndFuncShould solve your problem all together with or without the Opt. Edit: Had redundant code in there. Edited November 26, 2008 by SmOke_N 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...
Tomb Posted November 26, 2008 Author Share Posted November 26, 2008 very nice, with ControlGetHandle() and WinGetPos() i can return the correct position. thank you SmOke_N 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