bskendig@phoenix.Princeton.EDU (Brian Kendig) (08/22/89)
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! My Windows menu exists in a resource which I access through a handle to it. I am using Lightspeed C 3.0 for my coding. Any ideas? Anyone? Anyone? -- | Brian S. Kendig | I feel more like I | bskendig | | Computer Engineering | did when I got here | @phoenix.Princeton.EDU | | Princeton University | than I do now. | @PUCC.BITNET | | Systems Engineering, NASA Space Station Freedom / General Electric WP3 |
oster@dewey.soe.berkeley.edu (David Phillip Oster) (08/22/89)
Recently a tech note came out of Apple that said, don't access menu data structures directly. This tech note, I've been told, was written by the guy who is writing the System 7.0 menu manager. So, the best way to write a dynamic windows menu is to write an MDEF that has 32 dummy strings in it (so you won't screw up the menu bar's menu flashing hook.) but which draws items based on the window list: for(win = FrontWindow();win != NIL;win = (WindowPtr) ((WindowPeek) win)->nextWindow){ if(((WindowPeek) win)->visible){ /* it goes in the menu */ } } If you want help, the source code for Apple's MDEF is available on MacNet, and probably other places. It is in assembly language. I believe it was Tim Maroney who first wrote about this technique. To whoever did, Thank you! --- David Phillip Oster --"Unix Version 7 was an improvement not Arpa: oster@dewey.soe.berkeley.edu --only over its predeccessors, but also its Uucp: {uwvax,decvax}!ucbvax!oster%dewey.soe.berkeley.edu --successors."
tim@hoptoad.uucp (Tim Maroney) (08/22/89)
In article <10029@phoenix.Princeton.EDU> bskendig@phoenix.Princeton.EDU (Brian Kendig) writes: >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! Sure there is. DelMenuItem, described on IM IV-56. One of many indispensable routines added in the Mac Plus ROM.... Some day, a new Inside Mac should come out that combines all this stuff into single chapters. A lot of stuff in IV and V (and the no doubt forthcoming VI) seems to get missed just because they're organized as addenda rather than integrated into the main topic discussions. -- Tim Maroney, Mac Software Consultant, sun!hoptoad!tim, tim@toad.com "Something was badly amiss with the spiritual life of the planet, thought Gibreel Farishta. Too many demons inside people claiming to believe in God." -- Salman Rushdie, THE SATANIC VERSES
alms@brazil.cambridge.apple.com (Andrew L. M. Shalit) (08/22/89)
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! Is there some problem with calling the trap _DelMenuItem whenever a window is closed?
svc@well.UUCP (Leonard Rosenthol) (08/23/89)
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