Icon in DA Menu
Volume Number: 5
Issue Number: 4
Column Tag: Assembly Lab
Icons in DA Menus
By John A. Love, III, Springfield, VA
John got his start in the world of computers a long time ago on main frames while
serving in the U. S. Air Force. He has gone from the Apple ][ to the “Fat” Mac to his
SE. He can be found on GEnie (J.LOVE7).
I am currently writing a Desk Accessory in whose MENU Items I would like to
have ICONs. Immediately we have two seemingly disparate numbering systems as
dictated by “Inside Macintosh” {IM}. The first deals with the arithmetic pertaining to
IDs for Resources owned by Desk Accessories; the second pertains to IDs for ICONs
placed in MENU Items. Each set of arithmetic is simple enough to understand. The
challenge, of course, is their combined implementation in each of two different
operational environments.
Let’s quickly review the 1st numbering system pertaining to owned Resources.
The best way to accomplish this is the picture contained in Volume I of IM:
Figure 1. Resource ID of an Owned System Resource
Since a Desk Accessory is a DRVR-type Resource, the type bits = 000. The ID of
the owning Resource can be derived one of two ways, the most common of which relies
on dCtlRefNum in the Device Control Entry (DCE). The last 5 bits, earmarked
“variable”, are up for grabs so long, obviously, as the quantity is in the range 0 -->
31. Speaking of ranges, what this long word reduces to is a number in the range
= -16000 --> -15521 for a Desk Accessory.
NOW, what about the 2nd numbering system that addresses the IDs of ICONs for
MENU Items?? IM stipulates that these numbers be in the range 257 --> 511. Once
again it is obvious that when you load or create your MENUs in the Open Section of your
DRVR, you’ve got to temporarily change the high negative ID of your owned MENU ICON
to a low positive # before you call _SetItmIcon. No sweat, right ?*!!*? Yup, anything
you say !!
As if the above gymnastics weren’t enough, it turns out that “Suitcase” searches
for the 1st empty slot {a positive Unit # = the ID of the owning Resource} and
temporarily converts that to new IDs for your owned Resources. For example, if your
Source Code specifies a Unit # of 16 {mandatory range = 12 --> 26}, but “Suitcase”
detects an empty Slot #12, “Suitcase” will temporarily change all the IDs of your
DA’s owned Resources accordingly {I don’t know what “Font/DA Juggler Plus” does
behind the scenes}. Interesting, you say ?*!!*?
Before I address the solution to the above puzzle, I must praise to the skies both
the intelligence and patience of the following folk, without whom I would still be
groveling:
• Steve Brecher, author of “Suitcase”.
• Dave McWherter, author of
“McAssembly™” {$5000 SW} and the
“McSink” DA. By the way, the latter is now
called “Vantage™” and goes for $8995.
• Dave Smith..
By the way, if I blow it, I hereby declare that I am the sole occupant at the end of
this tree limb that I’m busily sawing off. Steve and the two Dave’s are not responsible
for any of my mistakes.
First, what does NOT work:
Open Section --> _GetResInfo {original ID}
; ------------------------------
Close Section --> _SetResInfo {original ID}
These gyrations won’t work in either operational environment. Oh, your MENU
ICONs will show up as advertised after you open your DA in both; however, upon
closing the DA, the new ID is still in place {257 -> 511} for the 1st environment
[using “Font/DA Mover”]. NO resetting was implemented. As you can see, I do NOT
call _WriteResource on closing, because then I would update the System File Resource
{YUCK !!} Even if I would be willing to suffer the latter, “Suitcase”, remember,
messes with the owned Resource ID and the reset would be back to its make-believe ID,
NOT my ID as stored on disk. “Ain’t life wonderful ??”
Okay, folks, how about making a copy of the Handle to your MENU ICONs, and,