Important: The information in this document is obsolete and should not be used for new development.
DragWindow
When the user drags a window by its title bar, use theDragWindowprocedure 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
wherefield 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 ofboundsRect,DragWindowreturns 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 setboundsRectto the largest available rectangle (the bounding box of the desktop region pointed to by the global variableGrayRgn) when you're usingDragWindowto 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
TheDragWindowprocedure 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,DragWindowcallsMoveWindowto 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),DragWindowmakes it the active window by setting thefrontparameter toTRUEwhen callingMoveWindow. If the Command key was down when the mouse button was pressed,DragWindowmoves the window without making it active.SEE ALSO
TheDragWindowprocedure calls bothMoveWindowandDragGrayRgn, which are described in this section.See Listing 4-9 on page 4-44 for an example that calls
DragWindowwhen the user presses the mouse button while the cursor is in the drag region.