I have different nested ContainerControls. One of them has a PushButton. After clicking on it I’d like to appear a MenuItem under the PushButton.
I Don’t want to use a BevelButton!
So the PopUp coordinates will be on PushButtons Top position + his height. While using TrueWindow to get the Windows correct position and add it to the PushButtons coordinates, it’s only working fine if a add one container directly to a window. But if a container owns some other containers with this PushButton, the position will be wrong. How can I every time get the correct position?
@Martin Trippensee Sorry, I used nested controls instead of nested ContainerControls. That brings us exactly to what Greg was talking about. Here is the code that works for me with nested ContainerControls.
[code]// In PushButton.Action
dim nx, ny as integer
dim rc as RectControl = me
nx = me.Left
ny = me.Top
while rc.Parent<>nil
rc = rc.Parent
nx = nx + rc.Left
ny = ny + rc.Top
wend
Dim popMenu As MenuItem
popMenu = EditMenu.Clone
call popMenu.Popup( me.Truewindow.Left + nx, me.TrueWindow.Top + ny + me.Height + 8 )[/code]
NOTE: the same code would run for any nested RectControl but it gives the right result only with embedded ContainerControls. You may want to add some type-checking