Does anyone know of a way to get the true screen xy coords of the top left hand corner of a specified gadget?
Ta
Ta
Global x%,y% w = CreateWindow("Test",100,200,300,400) p = CreatePanel(50,60,200,150,w,1) l = CreateLabel("Test",10,15,80,20,p,1) ScreenCoords(l) Notify x+", "+y While WaitEvent()<>$0803 : Wend End Function ScreenCoords(gadget) While gadget<>0 x=x+GadgetX(gadget) y=y+GadgetY(gadget) gadget=GadgetGroup(gadget) Wend End Function
; ----------------------------------------------------------------------------- ; 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