Legacy Documentclose button

Important: The information in this document is obsolete and should not be used for new development.

Previous Book Contents Book Index Next

Inside Macintosh: Macintosh Toolbox Essentials /
Chapter 4 - Window Manager / Window Manager Reference
Window Manager Routines / Moving Windows


DragWindow

When the user drags a window by its title bar, use the DragWindow procedure to move the window on the screen.

PROCEDURE DragWindow (theWindow: WindowPtr; 
                        startPt: Point; boundsRect: Rect);
theWindow
A pointer to the window record of the window to be dragged.
startPt
The location, in global coordinates, of the cursor at the time the user pressed the mouse button. Your application retrieves this point from the where field of the event record.
boundsRect
A rectangle, in global coordinates, that limits the region to which a window can be dragged. If the mouse button is released when the
cursor is outside the limits of boundsRect, DragWindow returns without moving the window (or, if it was inactive, without making
it the active window).
Because the user cannot ordinarily move the cursor off the desktop,
you can safely set boundsRect to the largest available rectangle (the bounding box of the desktop region pointed to by the global variable GrayRgn) when you're using DragWindow to track mouse movements. Don't set the bounding rectangle to the size of the immediate screen (screenBits.bounds), because the user wouldn't be able to move
the window to a different screen on a system equipped with
multiple monitors.
DESCRIPTION
The DragWindow procedure moves a dotted outline of the specified window around the screen, following the movement of the cursor until the user releases the mouse button. When the button is released, DragWindow calls MoveWindow to move the window to its new location. If the specified window isn't the active window (and the Command key wasn't down when the mouse button was pressed), DragWindow makes it the active window by setting the front parameter to TRUE when calling MoveWindow. If the Command key was down when the mouse button was pressed, DragWindow moves the window without making it active.

SEE ALSO
The DragWindow procedure calls both MoveWindow and DragGrayRgn, which are described in this section.

See Listing 4-9 on page 4-44 for an example that calls DragWindow when the user presses the mouse button while the cursor is in the drag region.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
11 JUL 1996