Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!apple!apple.com!rmh From: rmh@apple.com (Rick Holzgrafe) Newsgroups: comp.sys.mac.programmer Subject: Re: Icons in popup menus (like Std. File dialog)? Message-ID: <12338@goofy.Apple.COM> Date: 1 Mar 91 00:29:10 GMT Sender: usenet@Apple.COM Distribution: comp Organization: Apple Computer, Inc. Lines: 83 References:<62972@bbn.BBN.COM> <11707@adobe.UUCP> <11012@jarthur.Claremont.EDU> In article <11012@jarthur.Claremont.EDU> jwinterm@jarthur.Claremont.EDU (Jim Wintermyre) writes: > Macintosh technical note #253 documents how to include SICNs or reduced > size regular ICONs next to menu items, like Multifinder does. This > facility came about when Multifinder was being created, so it isn't > documented in Inside Mac. > [...] since the cmdChar field is used up, you can't have > keyboard equivalents for these menu items. Furthermore, it doesn't work on pre-MultiFinder systems - instead you get a mess of ersatz command-chars and icons, I don't remember the precise symptoms but they were UGLY. I wanted to use small icons in my menus when possible, but not freeze out users of older systems. The following code worked for me. Please note that it is *NOT*NOT*NOT* official Apple-approved code, it's just my hack. void CStarterApp::SetUpMenus(void) { extern Boolean gHasWNE; /* Is WaitNextEvent implemented? */ /* * Find out if we can support small icons, * and turn them off if not. */ if (!gHasWNE) { extern void TurnOffSICN (short theMenuCmd); TurnOffSICN (cmdAlignRight); TurnOffSICN (cmdAlignCenter); TurnOffSICN (cmdAlignLeft); /* And so on... */ } } void TurnOffSICN (short theMenuCmd) { MenuHandle mh; short theItem; short theMenuID; Ptr p; short i; gBartender->FindMenuItem (theMenuCmd, &theMenuID, &mh, &theItem); SetItemIcon (mh, theItem, 0); /* * Very bad karma to play with a manager's internal * structures like this: they could change in the * future and leave us stranded. But this code is * called only for pre-multifinder systems, so * we're safe. (I hope!) * * This code turns off the "keyboard equivalent char", * which in this case was really a flag to indicate * the use of small rather than regular icons. */ p = (Ptr)*mh; p += 14; p += (*p + 1); /* Skip the menu info and title */ /* p now points to a menu item */ for (i = 1; i < theItem && *p != 0; i++) { p += (*p + 1); /* Skip the menu item title */ p += 4; /* Skip the other menu item info */ } if (*p != 0) { p += (*p + 1); /* Skip the menu item title */ p++; /* Point to the keyboard equivalent */ *p = 0; /* Erase it! */ } } Hope this helps. ========================================================================== Rick Holzgrafe | {sun,voder,nsc,mtxinu,dual}!apple!rmh Software Engineer | AppleLink HOLZGRAFE1 rmh@apple.com Apple Computer, Inc. | "All opinions expressed are mine, and do 20525 Mariani Ave. MS: 3-PK | not necessarily represent those of my Cupertino, CA 95014 | employer, Apple Computer Inc."