Now, parents are no more what they were in the past:
In the past (API 1), things were simpler:
a control had a parent (a window, a container or a control) and, logically, this parent had coordinates.
It was easy to get coordinates of the control inside a window (we need that to display a menuitem at a specific place).
Now (API 2) parent is… on object !
I don’t see in what else than a container or a control or a window a control can be embedded…
Now, if we want to get the coordinates of a control which is inside a canvas which is inside a container which is inside a pagepanel (we have this case)… we have to do a complex code like:
Oh no ! Things are more complex than in the following code:
a control inside a control has coordinates inside its window, but when a control is inside a container that is inside a control…
Fixed now inside the code…
var ctrl as DesktopUiControl var ctn as DesktopContainer var trueLeft,trueTop as integer trueLeft = me.left trueTop = me.top if me.Parent isa DesktopUiControl then ctrl = DesktopUiControl(me.Parent) elseif me.Parent isa DesktopContainer then ctn = DesktopContainer(me.Parent) end if if ctn <> nil or ctrl <> nil then while true if ctn <> nil then trueLeft = trueLeft + ctn.Left trueTop = trueTop + ctn.top elseif ctrl <> nil then 'trueLeft = trueLeft + ctrl.Left 'trueTop = trueTop + ctrl.top end if if ctn <> nil then ctrl = nil if ctn.Parent isa DesktopUiControl then ctrl = DesktopUiControl(ctn.Parent) ctn = nil elseif ctn.Parent isa DesktopContainer then ctn = DesktopContainer(ctn.Parent) else exit end if else ctn = nil if ctrl.Parent isa DesktopUiControl then ctrl = DesktopUiControl(ctrl.Parent) elseif ctrl.Parent isa DesktopContainer then ctn = DesktopContainer(ctrl.Parent) ctrl = nil else exit end if end if wend end if
Silly, no ?
Having direct properties for controls and containers coordinates like leftinwindow, topinwindow would be a good thing.