Hi Yiannis, on your popup ending out-of-place.
For all window types - EXCEPT CHILD:
- <X, Y> is outer top-left corner of the window relative to monitor (incl. which monitor in multi-monitor setup).
- <WorkSpaceX( ), WorkspaceY( )> is inner top-left corner of window relative to monitor.
- This adjusts for window border, titlebar, menubar, etc.
- For non-MDI frame windows this also adjusts for toolbar
For MDI frames in particular:
- <MDI_1.X, MDI_1.Y> is MDI client area's top-left corner within the workspace adjusted for MDI toolbar
For CHILD windows in particular
- <X, Y> is outer top-left corner of the window relative to its "parent" window.
- <0, 0> = top-left corner inside "parent" window's workarea.
Here follows code to move any window type to top-left corner or the practical work area of a previously defined "origin" window. When that origin is MDI frame the code coordinate logic also needs reference to the built-in MDI client area inside that MDI frame.
// Instance variables
Window iw_origin
Boolean ib_isMDI
MDIClient imdi_area
// - - - -
FUNCTION of_SnapTopLeft(window aw_object)
long newX, newY
if aw_object.WindowType <> Child! then
newX = iw_origin.WorkSpaceX( )
newY = iw_origin.WorkSpaceX( )
end if
if ib_isMDI then
newX += imdi_area.X
newY += imdi_area.Y
end if
aw_object.Move(newX, newY)
END FUNCTION
GetSystemMetrics (SM_CXBORDER) returned only 1 pixel, which is a lot less than the difference between the frame and the popup window.
On the other hand, using win.WorkspaceX() - win.X made the difference and eliminated the difference between the frame and the popup window. That worked well in my simple test application, but it's of no use in my real application, since it contains a user object on the MDIFrame, and in that cases WorkSpaceX() returns always 0...