For future readers - PBDTGetIcon updates your supplied PBDTRecord’s ioDTBuffer data with the icon data(first the icon bits and then the mask bits), not a bit map directly. So yes to your final point that you can just set a BitMap’s baseAddr field to point to the first address of your bits (in my case captured as a Str256 to hold both 32x32 icon and then mask data).PlotIcon is what you need, confusingly in the Toolbox Utilities chapter. Or of course you can always stuff your icon into a bitmap and use CopyBits.
Edit: of course you aren’t actually getting an ICON resource this is just showing you how to draw it. I don’t remember if PBDTGetIcon() gives you back a pointer to a bitmap already — I think it does — in that case you can just pass that pointer to CopyBits. If not, it sounds like you know where the underlying icon bitmap data is, and you can just use a pointer to that data as the b.baseAddr below and plot it with CopyBits anyway.
C:BitMap b = {NULL, 4, {0, 0, 32, 32} }; const Handle icon = GetResource(‘ICON’, 128); HLock(icon); b.baseAddr = *icon; CopyBits(&b, &thePort->portBits, &b.bounds, &b.bounds, srcCopy, NULL);
just wanted to add that for any future readers. Great help! Thanks again.
I’ll add, and this is no surprise, that the biggest benefit of this little self exercise is that I’ve been forced to use Inside Macintosh and in doing so learned how to navigate it as well as gotten a good feel for the paradigm apple used to supply data inputs and outputs to their functions. This is foundational learning that transforms the programmer from “poking around someone else’s house” into truly taking ownership where one’s skill can be applied.
Good stuff!
Last edited: