I have a container (section) inside a container (page) inside a window.
I wanted to place the modal window, just below the control in the section container.
Unfortunately, the modal window’s location is based on the origin of the window.
And from the nested container, there is no way to know the relative location from the window.
Is there an easy way to find the location of section container location based on
the main window, regardless of how many containers are embedded in between??
My intention was to show the date popup under the date dropdown looking control
TrueWindow property of the
ContainerControl to get a reference to the base window.
I understand that the base window can be reference using
TrueWindow, but how would I know the location of the container from the base window?
Maybe make a recursive function to walk the parent hierarchy until you get to the base window, accumulating the offsets? Each container’s location within its parent will be
self.top; add these up recursively (including the base window if you want the global position).
Function GetLocationBasedOnMainWindow ( c as ContainerControl )
Var tc As RectControl
Var p As New Point
tc = c.parent
p.x = c.Left
p.y = c.top
While tc <> Nil
p.x = p.x + tc.Left
p.y = p.y + tc.top
tc = tc.parent
p.X = p.X + MainWindow.Left
p.Y = p.Y + MainWindow.Top
Seems to do the trick.
@Matthew_Dinmore1 Thanks for the suggestion. I was hoping there would be some function to help me out, but instead had to create a code to loop through the parent controls.