Important: The information in this document is obsolete and should not be used for new development.
FindWindow
When your application receives a mouse-down event, call theFindWindow
function to map the location of the cursor to a part of the screen or a region of a window.
FUNCTION FindWindow (thePoint: Point; VAR theWindow: WindowPtr): Integer;
- thePoint
- The point, in global coordinates, where the mouse-down event occurred. Your application retrieves this information from the
where
field of the event record.- theWindow
- A parameter in which
FindWindow
returns a pointer to the window in which the mouse-down event occurred, if it occurred in a window. If it didn't occur in a window,FindWindow
setstheWindow
toNIL
.DESCRIPTION
TheFindWindow
function returns an integer that specifies where the cursor was when the user pressed the mouse button. You typically callFindWindow
whenever you receive a mouse-down event. TheFindWindow
function helps you dispatch the event by reporting whether the cursor was in the menu bar or in a window when the mouse button was pressed and, if it was in a window, which window and which region of the window. If the mouse-down event occurred in a window,FindWindow
places a pointer to the window in the parametertheWindow
.The
FindWindow
function returns an integer that specifies one of nine regions:
CONST inDesk = 0; {none of the following} inMenuBar = 1; {in menu bar} inSysWindow = 2; {in desk accessory window} inContent = 3; {anywhere in content region except size } { box if window is active, } { anywhere including size box if window } { is inactive} inDrag = 4; {in drag (title bar) region} inGrow = 5; {in size box (active window only)} inGoAway = 6; {in close box} inZoomIn = 7; {in zoom box (window in standard state)} inZoomOut = 8; {in zoom box (window in user state)}TheFindWindow
function returnsinDesk
if the cursor is not in the menu bar, a desk accessory window, or any window that belongs to your application. TheFindWindow
function might return this value if, for example, the user presses the mouse button while the cursor is on the window frame but not in the title bar, close box, or zoom box. WhenFindWindow
returnsinDesk
, your application doesn't need to do anything. In System 7, when the user presses the mouse button while the cursor is on the desktop or in a window that belongs to another application, the Event Manager sends your application a suspend event and switches to the Finder or another application.The
FindWindow
function returnsinMenuBar
when the user presses the mouse button with the cursor in the menu bar. Your application typically adjusts its menus and then calls the Menu Manager's functionMenuSelect
to let the user choose menu items.The FindWindow function returns
inSysWindow
when the user presses the mouse button while the cursor is in a window belonging to a desk accessory that was launched in your application's partition. This situation seldom arises in System 7. When the user clicks in a window belonging to a desk accessory launched independently, the Event Manager sends your application a suspend event and switches to the desk accessory.If
FindWindow
does returninSysWindow
, your application calls theSystemClick
procedure, documented in the chapter "Event Manager" in this book. TheSystemClick
procedure routes the event to the desk accessory. If the user presses
the mouse button with the cursor in the content region of an inactive desk
accessory window,SystemClick
makes the window active by sending your application and the desk accessory the appropriate activate events.The
FindWindow
function returnsinContent
when the user presses the mouse button with the cursor in the content area (excluding the size box in an active window) of one of your application's windows. Your application then calls its routine for handling clicks in the content region.The
FindWindow
function returnsinDrag
when the user presses the mouse button with the cursor in the drag region of a window (that is, the title bar, excluding the close box and zoom box). Your application then calls the Window Manager'sDragWindow
procedure to let the user drag the window to a new location.The
FindWindow
function returnsinGrow
when the user presses the mouse button with the cursor in an active window's size box. Your application then calls its own routine for resizing a window.The
FindWindow
function returnsinGoAway
when the user presses the mouse
button with the cursor in an active window's close box. Your application calls theTrackGoAway
function to track mouse activity while the button is down and then
calls its own routine for closing a window if the user releases the button while the
cursor is in the close box.The
FindWindow
function returnsinZoomIn
orinZoomOut
when the user presses the mouse button with the cursor in an active window's zoom box. Your application calls theTrackBox
function to track mouse activity while the button is down and then calls its own routine for zooming a window if the user releases the button while the cursor is in the zoom box.SEE ALSO
See Listing 4-9 on page 4-44 for an example that callsFindWindow
to determine the location of the cursor and then dispatches the mouse-down event depending on
the results.