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 theFindWindowfunction 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
wherefield of the event record.- theWindow
- A parameter in which
FindWindowreturns 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,FindWindowsetstheWindowtoNIL.DESCRIPTION
TheFindWindowfunction returns an integer that specifies where the cursor was when the user pressed the mouse button. You typically callFindWindowwhenever you receive a mouse-down event. TheFindWindowfunction 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,FindWindowplaces a pointer to the window in the parametertheWindow.The
FindWindowfunction 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)}TheFindWindowfunction returnsinDeskif the cursor is not in the menu bar, a desk accessory window, or any window that belongs to your application. TheFindWindowfunction 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. WhenFindWindowreturnsinDesk, 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
FindWindowfunction returnsinMenuBarwhen 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 functionMenuSelectto let the user choose menu items.The FindWindow function returns
inSysWindowwhen 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
FindWindowdoes returninSysWindow, your application calls theSystemClickprocedure, documented in the chapter "Event Manager" in this book. TheSystemClickprocedure 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,SystemClickmakes the window active by sending your application and the desk accessory the appropriate activate events.The
FindWindowfunction returnsinContentwhen 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
FindWindowfunction returnsinDragwhen 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'sDragWindowprocedure to let the user drag the window to a new location.The
FindWindowfunction returnsinGrowwhen 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
FindWindowfunction returnsinGoAwaywhen the user presses the mouse
button with the cursor in an active window's close box. Your application calls theTrackGoAwayfunction 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
FindWindowfunction returnsinZoomInorinZoomOutwhen the user presses the mouse button with the cursor in an active window's zoom box. Your application calls theTrackBoxfunction 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 callsFindWindowto determine the location of the cursor and then dispatches the mouse-down event depending on
the results.