Moving a Window

When the user drags a window, the window should move, following the cursor as it moves on the desktop. By calling the pre-Mac OS 8.5 Window Manager function DragWindow , your application lets the user move the window. When your application wishes to move a window for a reason other than a user-instigated drag, however, it should use either the Mac OS 8.5 Window Manager function MoveWindowStructure or the earlier function MoveWindow .

On versions of the Mac OS that include the Appearance Manager, the size and shape of a window frame may vary from appearance to appearance. Because of this, the total dimensions of a window (that is, the window's structure region) may also vary, causing the window's spatial relationship to the rest of the screen to change. Your application can best accommodate variable window dimensions by using Window Manager functions to size and position your windows, rather than via constant dimensions. Using these functions also allows your application to avoid maintaining its own table of window definition IDs and their various border dimensions, as well as ensuring your application's support of future window definitions.

The MoveWindowStructure function moves the specified window, but does not change the window's size. When your application calls MoveWindowStructure , the positioning of the specified window is determined by the positioning of its structure region. This is in contrast to the MoveWindow function, where the positioning of the window's content region determines the positioning of the window.

The function SetWindowBounds also provides a means of moving a window, but you would typically call SetWindowBounds when you wish to set the size of a window as well. The SetWindowBounds function sets a window to the size and position of a rectangle that you specify, and it can interpret this rectangle as the bounding rectangle for either the window's structure or content region (your choice).

In general, you should specify the structure region as the determining basis if how the window as a whole relates to a given monitor is more important than the exact positioning of its content on the screen. If you specify the content region--because the positioning of your application's content is of greatest concern--it is important to note that under some appearances some part of the window's structure region or "frame" may extend past the edge of a monitor and not be displayed.

Finally, setting a window's position may also be done algorithmically, via the function RepositionWindow , which positions a window relative to another window or a display screen. See Positioning a Window on the Desktop for a discussion of algorithmic window positioning on Mac OS 8.5.


� 1999 Apple Computer, Inc. – (Last Updated 18 March 99)