[comp.sys.mac.programmer] Changing ICONs on the fly in dialogs

mcdonald@fornax.UUCP (Ken Mcdonald) (03/04/90)

I'm doing some fiddling with icons in dialogs, and need to be able to
change them on the fly.  This is easily accomplished with SetDItem,
except that this procedure does not redraw the icon--hence the old,
not the new icon, is left in the dialog box.  I've tried to use
PlotIcon to rectify this, but the icon came out in the wrong place,
and also tried using InvalRect, to accumulate the rect to be
drawn into the dialog's update region, which causes a crash.  
Inspection with the source-level debugger shows that thePort during
the dialog's existence is the same as thePort right after I start
my test shell, before the dialog is created.  Is this supposed to
happen?  I'm not very much up on QuickDraw and the Window Manager,
but I thought thePort would be set to the dialog's GrafPort when
the dialog was created.

Thanks for the help,
Ken McDonald
{mcdonald@cs.sfu.ca}

zben@umd5.umd.edu (Ben Cranston) (03/06/90)

In article <391@fornax.UUCP> mcdonald@fornax.UUCP (Ken Mcdonald) writes:

> Inspection with the source-level debugger shows that thePort during
> the dialog's existence is the same as thePort right after I start
> my test shell, before the dialog is created.  Is this supposed to
> happen?  I'm not very much up on QuickDraw and the Window Manager,
> but I thought thePort would be set to the dialog's GrafPort when
> the dialog was created.

BAD misassumption.  The Toolbox is defined NEVER to change thePort on you.
Always SetPort and SelectWindow your own windows.  This was my second real
bad starting-up misassumption (the first was not initializing the managers).

-- 
Sig     DS.L    ('ZBen')       ; Ben Cranston <zben@Trantor.UMD.EDU>
* Network Infrastructures Group, Computer Science Center
* University of Maryland at College Park
* of Ulm