This seems to work (uses userlibs):
; -----------------------------------------------------------------------------
; IMPORTANT: Add this line to user32.decls in your userlibs folder...
; -----------------------------------------------------------------------------
; ClientToScreen% (window, point*): ClientToScreen
; -----------------------------------------------------------------------------
window = CreateWindow ("Test", 0, 0, 208, 80, 0, 1)
; Will retrieve screen co-ords of 'gadget', below...
gadget = CreateButton ("My screen co-ords are below!", 0, 0, 200, 25, window)
Type Point
Field x, y
End Type
p.Point = New Point
textfield = CreateTextField (0, 30, 200, 25, window)
Repeat
; Set point in gadget to be converted:
p\x = 0
p\y = 0
ClientToScreen (QueryObject (gadget, 1), p)
; p.Point now contains the co-ords 0, 0 in 'gadget', converted to screen space...
SetGadgetText textfield, "X: " + p\x + " -- Y: " + p\y
Until WaitEvent () = $803
End
|