Jump to content

Recommended Posts

Posted

Not sure if this is the right place, but here it goes.

In the help file example for GUICtrlCreateContextMenu, the second example makes use of a function ClientToScreen(), this takes the coords of a control within a parent window and figures out where the exact coords are on the screen.

But you could accomplish the same results by using WinGetPos on the control's handle.

Func _ControlGetScreenPos($hWnd, $sText, $iCtrl)
    Local $hCtrl = ControlGetHandle($hWnd, $sText, $iCtrl)
    Return WinGetPos($hCtrl)
EndFunc

Run('notepad.exe')
WinWait('Untitled - Notepad')

$aClient = ControlGetPos('Untitled', '', 'Edit1')
$aScreen = _ControlGetScreenPos('Untitled', '', 'Edit1')

MsgBox(0, 'Coords of Edit control', 'Client: ' & $aClient[0] & 'x' & $aClient[1] & @LF & _
    'Screen: ' & $aScreen[0] & 'x' & $aScreen[1])oÝ÷ Ø×¶¡wb*.ßÚÞ$x¢¶§ëh"×+y«^uÊ'¶º%ßۢݲ+wöǯzw²'«jëh×6GUICreate('', 200, 200)
$bt = GUICtrlCreateButton('Hello', 50, 50, 100, 100)
GUISetState()

$hCtrl = GUICtrlGetHandle($bt)
$aPos = WinGetPos($hCtrl)

MsgBox(0, 'Coords', $aPos[0] & 'x' & $aPos[1])

Well, I thought it was neat anyway.

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
×
×
  • Create New...