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 / Retrieving Window Information


FindWindow

When your application receives a mouse-down event, call the FindWindow 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 sets theWindow to NIL.
DESCRIPTION
The FindWindow function returns an integer that specifies where the cursor was when the user pressed the mouse button. You typically call FindWindow whenever you receive a mouse-down event. The FindWindow 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 parameter theWindow.

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)}
The FindWindow function returns inDesk if the cursor is not in the menu bar, a desk accessory window, or any window that belongs to your application. The FindWindow 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. When FindWindow returns inDesk, 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 returns inMenuBar 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 function MenuSelect 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 return inSysWindow, your application calls the SystemClick procedure, documented in the chapter "Event Manager" in this book. The
SystemClick 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 returns inContent 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 returns inDrag 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's DragWindow procedure to let the user drag the window to a new location.

The FindWindow function returns inGrow 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 returns inGoAway when the user presses the mouse
button with the cursor in an active window's close box. Your application calls the TrackGoAway 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 returns inZoomIn or inZoomOut when the user presses the mouse button with the cursor in an active window's zoom box. Your application calls the TrackBox 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 calls FindWindow to determine the location of the cursor and then dispatches the mouse-down event depending on
the results.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
11 JUL 1996