>Is SysCopyStringResource the right API to use to access individual strings
>created with constructor?
It depends. If the strings are short and have a well-bounded maximum
length, then SysCopyStringResource is a good choice.
The problems with it are that you're copying data, and the buffer has
to be pre-allocated to a max size. Calculating a safe max size can be
a problem, especially with text that needs to be localized.
A third issue is that if the string data has to stick around for a
while (e.g. you're using it for a form title or control label), then
you'll have to allocate/deallocate the string buffer or make it a
global variable.
The other approach is to directly use the locked string resource
data. For example, you could have a routine like this:
const Char* GetStringResource(DmResID strID)
{
MemHandle h = DmGetResource(strRsc, strID);
ErrNonFatalDisplayIf(h == NULL, "Missing string resource");
return((const Char*)MemHandleLock(h));
}
You have to remember to unlock the ptr and call DmReleaseResource on
the recovered handle when you're done using the string data.
There was a similar thread on this topic (using SysStringByIndex
versus getting the resource yourself) back in September of last year.
-- Ken
Ken Krugler
TransPac Software, Inc.
<http://www.transpac.com>
+1 530-470-9200
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/