rizaado Posted June 25, 2015 Share Posted June 25, 2015 (edited) Func GUICtrlGetPos($iControlID) Local $hControlID = GUICtrlGetHandle($iControlID) Local $aControlPos[2] $aControlPos[0] = ControlGetPos($hControlID, "", 0)[0] $aControlPos[1] = ControlGetPos($hControlID, "", 0)[1] Return $aControlPos EndFunc ;==>GUICtrlGetPosLocal $hGUI = GUICreate("GUICtrlGetPos", _ 0, _ 0, _ 1, _ 1, _ $WS_SYSMENU + $WS_MAXIMIZE + $WS_MAXIMIZEBOX + $DS_MODALFRAME) Local $idPic = GUICtrlCreatePic("tree.gif", 20, 40, 11, 26) GUISetState(@SW_SHOW) MsgBox($MB_SYSTEMMODAL, "Left", GUICtrlGetPos($idPic)[0]) MsgBox($MB_SYSTEMMODAL, "Top", GUICtrlGetPos($idPic)[1]) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd GUIDelete($hGUI)Purpose: Get the left(x) and top(y) of control. Edited June 30, 2015 by rizaado Link to comment Share on other sites More sharing options...
argumentum Posted June 25, 2015 Share Posted June 25, 2015 (edited) Func GUICtrlGetPos($iControlID) Local $a = ControlGetPos(GUICtrlGetHandle($iControlID),"",0) If @error Then Local $a[4]=[-1,-1,-1,-1] Return SetError(1,0,$a) EndIf Return SetError(0,0,$a) EndFunc Edited June 30, 2015 by argumentum corrected the function mLipok 1 Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting. Link to comment Share on other sites More sharing options...
rizaado Posted June 30, 2015 Author Share Posted June 30, 2015 (edited) Your variant of a function GUICtrlGetPos is wrong.ControlGetPos:Return ValueSuccess:an array containing the size and the control's position relative to its client window: $aArray[0] = X position $aArray[1] = Y position $aArray[2] = Width $aArray[3] = HeightFailure:sets the @error flag to 1. Edited June 30, 2015 by rizaado Link to comment Share on other sites More sharing options...
rizaado Posted July 1, 2015 Author Share Posted July 1, 2015 (edited) Divide GUICtrlGetPos into two functions - "getLeft" and "getTop"! It is better solution. Edited July 1, 2015 by rizaado Link to comment Share on other sites More sharing options...
JohnOne Posted July 1, 2015 Share Posted July 1, 2015 What exactly is this function useful for? AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
rizaado Posted July 3, 2015 Author Share Posted July 3, 2015 Purpose: Get the left(x) and top(y) of control. https://www.autoitscript.com/forum/topic/173621-guictrlget-left-top-width-and-height/ Link to comment Share on other sites More sharing options...
JohnOne Posted July 4, 2015 Share Posted July 4, 2015 I know what it does, just wondering what its practical use would be. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. 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