Jump to content

Function GUICtrlGetPos


rizaado
 Share

Recommended Posts

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   ;==>GUICtrlGetPos
Local $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 by rizaado
Link to comment
Share on other sites

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 by argumentum
corrected the function

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Link to comment
Share on other sites

Your variant of a function GUICtrlGetPos is wrong.

ControlGetPos:

Return Value

Success: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] = Height
Failure:sets the @error flag to 1.
Edited by rizaado
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...