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 theDragWindow
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 ofboundsRect
,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 setboundsRect
to the largest available rectangle (the bounding box of the desktop region pointed to by the global variableGrayRgn
) when you're usingDragWindow
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
TheDragWindow
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
callsMoveWindow
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 thefront
parameter toTRUE
when callingMoveWindow
. If the Command key was down when the mouse button was pressed,DragWindow
moves the window without making it active.SEE ALSO
TheDragWindow
procedure calls bothMoveWindow
andDragGrayRgn
, 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.