Hello Frank,
The GetWindowRect method will get a rectangle containing screen coordinates. The MoveWindow method expects a rectangle with coordinates relative to the parent window.
The following code snippet will show you how to convert coordinates. The code is similar to your code but the window will not move as you expected to see with your code.
// Get rectangle for active child window.
Page pg = Project.Pages();
Window winChild = pg.GetWindow();
RECT rectChild;
winChild.GetWindowRect(&rectChild);
// Get parent window of active page.
Window winParent = winChild.GetParent();
// Convert child's screen coordinates to coordinates
// relative to parent window.
winParent.ScreenToClient(&rectChild);
// Move child window.
winChild.MoveWindow(&rectChild);
You are correct. The GetWindowRect gets the rectangle for the entire window. This includes borders, caption, menu, etc. If you want just the area used for displaying data then you can call the GetClientRect method. Comparing the rectangles returned by GetClientRect and GetWindowRect will allow you to determine the size of a window's borders. You will also find the ClientToScreen method useful too.
Edited by - eparent on 04/08/2005 11:17:45 AM