Gadget Screen XY Coords?

BlitzPlus Forums/BlitzPlus Programming/Gadget Screen XY Coords?

My first inclination, though a little intricate and more complex than it should have to be, is to get the coords of the specified gadget with GadgetX and GadgetY, then do the same with its parent gadget (use GadgetGroup), add the results, and repeat until you reach the desktop.

Something like this:
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