Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.csd.uwm.edu!bionet!apple!well!svc From: svc@well.UUCP (Leonard Rosenthol) Newsgroups: comp.sys.mac.programmer Subject: Re: How do I do dynamic menus (adding/removing entries)? Summary: See InsMenuItem and DelMenuItem Keywords: Menus, Dynamic, me Message-ID: <13269@well.UUCP> Date: 22 Aug 89 17:01:45 GMT References: <10029@phoenix.Princeton.EDU> Reply-To: svc@well.UUCP (Leonard Rosenthol) Organization: Whole Earth 'Lectronic Link, Sausalito, CA Lines: 29 In article <10029@phoenix.Princeton.EDU> bskendig@phoenix.Princeton.EDU (Brian Kendig) writes: >I have a program that involves several numbered text windows. At any time, >the user can create a new window or close an old one. > >I'd like to have a 'Windows' menu from which the user can select any one >of the currently-open windows. I have no trouble adding an item to the >menu for each window I create, but there are no routines for removing >items from the menu whenever I close a window! > You must have missed the menuManager chapter of IM IV. On Pages 55 and 56 I find the following routines for doing what you wish (I use them for keeping my own Windows Menu in appls). DelMenuItem(menu:MenuHandle; item:integer); InsMenuItem(menu:MenuHandle; str: Str255; item:integer); This makes it real easy to simply add and delete the menu items which are associated with the windows. You will also need a routine which parses the menu and finds the item which matches the window title in order to delete it, but that is pretty simple. Another nice thing to do is to keep the window list in alphabetical order so that the user can find things quickly with lots of windows open. You should also use some sort of mark (check, diamond, etc.) to signal which is the frontmost window. -- +--------------------------------------------------+ Leonard Rosenthol | GEnie : MACgician Lazerware, inc. | MacNet: MACgician UUCP: svc@well.UUCP | ALink : D0025