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 / Closing and Deallocating Windows


CloseWindow

Use the CloseWindow procedure to remove a window if you allocated memory yourself for the window's window record.

PROCEDURE CloseWindow (theWindow: WindowPtr);
theWindow
A pointer to the window record of the window to be closed.
DESCRIPTION
The CloseWindow procedure removes the specified window from the screen and deletes it from the window list. It releases the memory occupied by all data structures associated with the window except the window record itself.

If you allocated memory for the window record and passed a pointer to it as one of the parameters to the functions that create windows, call CloseWindow when you're done with the window. You must then call the Memory Manager procedure DisposePtr to release the memory occupied by the window record.

WARNING
If your application allocated any other memory for use with a window, you must release it before calling CloseWindow. The Window Manager releases only the data structures it created.
Also, CloseWindow assumes that any picture pointed to by the window record field windowPic is data, not a resource, and it calls the QuickDraw procedure KillPicture to delete it. If your application uses a picture stored as a resource, you must release the memory it occupies with the ReleaseResource procedure and set the windowPic field to NIL before closing the window.
Any pending update events for the window are discarded. If the window being removed is the frontmost window, the window behind it, if any, becomes the active window.

SEE ALSO
See Listing 4-17 on page 4-61 for an example that calls CloseWindow to remove a window from the screen.

See Listing 4-3 on page 4-28 for an example that calls CloseWindow to clean up memory when an attempt to create a new window fails.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
11 JUL 1996