[comp.sys.mac.programmer] GetResource in DA's

volaski@acsu.buffalo.edu (12/18/89)

I recently posted here regarding a question about using dialogs in DA's, but 
got no response! 

Anyway, it appears the problem isn't related to dialogs per se. It appears 
that calls to GetResource do not work! This occurs when, first, the DA is 
running under SuitCase II, and, two, on an control call to the DA. On an open
call, everything works fine. GetResource simply returns a nil handle.

Maurice Volaski
Dept. of Physiology
University at Buffalo

tim@hoptoad.uucp (Tim Maroney) (12/19/89)

In article <14956@eerie.acsu.Buffalo.EDU> volaski@acsu.buffalo.edu () writes:
>I recently posted here regarding a question about using dialogs in DA's, but 
>got no response! 
>
>Anyway, it appears the problem isn't related to dialogs per se. It appears 
>that calls to GetResource do not work! This occurs when, first, the DA is 
>running under SuitCase II, and, two, on an control call to the DA. On an open
>call, everything works fine. GetResource simply returns a nil handle.

The only thing I can think of is that you must be miscomputing the
base-relative id of your resource.  If so, then you wouldn't see any
resource.  All resource IDs for a DA are computed relative to a base
address, which changes if you install the resource using Font/DA
Mover.  If your resource is incorrectly numbered or your calculations
are wrong, you won't see the resource you're looking for.  Break on
GetResource in Macsbug, find out the ID you're really looking for from
the stack, then go back into run-time mode and look for the resource
with that id (using ResEdit).

Computation of owned resource ids is covered on IM I-109-110.
-- 
Tim Maroney, Mac Software Consultant, sun!hoptoad!tim, tim@toad.com

Feminism that refuses to use the word "patriarchy" is kin to abolitionism
that refuses to use the word "slavery".

brecher@well.UUCP (Steve Brecher) (12/21/89)

In article <9338@hoptoad.uucp>tim@hoptoad.UUCP (Tim Maroney) writes:
> Break on GetResource in Macsbug, find out the ID you're really looking
> for from the stack, then go back into run-time mode and look for the
> resource with that id (using ResEdit).

This is likely to cause confusion if Suitcase II is used.  Suitcase II
dynamically assigns unit numbers to DAs, and maps the ID passed to
GetResource to the ID in the suitcase (or System) file.  So the ID
passed to GetResource would typically differ from the ID ResEdit
shows.

The original query was due to a nil handle returned by GetResource
called from a DA's control routine, whereas the call succeeded when
called from the open routine.  The only two reasons I can think of
for this are:  (1) different and incorrect calculation of the owned
resource ID in the control routine as compared with the Open routine;
(2) the call is really failing, due to some error such as insufficient
memory.  Any such error other than resNotFound would be indicated by
a nonzero return from ResError().
-- 

brecher@well.UUCP (Steve Brecher)