Window Menu
Volume Number: 5
Issue Number: 7
Column Tag: ABC's of Macintosh
A Window Menu 
By Clifford Story, Goleta, CA
The Standard Window Menu
A Macintosh program with several windows really ought to have a Window menu.
This menu is a list of all open application windows; choosing a window from the menu
brings it to the front.
The problem for the programmer is menu maintenance. Every time the program
opens a new window, the window’s name has to be added to the Window menu, and, what
is worse, every time a window is closed, its name must be removed from the menu.
There is no ROM trap to delete a menu item in the 64K ROM.
Still uglier problems arise if the menu is supposed to be kept in order. Every
time a window is selected, the window order changes, and the menu must be
re-ordered.
One solution: each time the menu must be updated, delete the whole menu and
recreate it from the window list. That isn’t very pretty, but it would work.
The solution I present here is similar but less work: Draw the menu with an
MDEF that reads the window list. This approach requires virtually no menu
maintenance (only a call to CalcMenuSize when a window is opened or closed). As an
extra, the menu includes a “Zoom Front Window” item.
Advertisement
This is my third article for MacTutor, and I’ve got a fourth and a fifth in the
works. Maybe I’m becoming a regular? Anyway, I thought I might mention ways to
respond to my stuff.
The cheapest way is by mail:
Clifford Story
Attic Software
P.O. Box 219
Goleta, California 93116
The fastest way is by modem. I run a BBS called THE ATTIC, phone number
(805) 683-0322, hours 6:00 PM to 2:00 AM, Pacific time, daily. The board isn’t
very active, but I read and respond each morning.
#****************************************
# Window.make
# MPW make file for
# dynamic Window menu demo
# (c) 1988, by Clifford Story
# & Attic Software
#****************************************
#****************************************
# Compile the resources