Steve Austin wrote:
> handle = DmNewHandle(resourceDB, sizeof(FormType));
> newResource = MemHandleLock(handle);
> DmWrite(newResource, formPtr);
> DmAttachResource(resourceDB, 'tFRM', handle);
That won't work. The format of a 'tFRM' resource is different from the
format of loaded FormType object. It's similar, but all the string
pointers are stored in the resource as offsets, not pointers. (There
may be other subtleties too.) So you'll need to add code to basically
un-fixup those things before storing.
(If you have OS source, see the ResLoadForm function, which is what
converts from 'tFRM' format to FormType format.)
> My main concern is that the form has a list of objects (fields,
> labels, buttons). Do I need to calculate
> the size of these items as well as that of the form
Yes, the objects are tacked on serially in memory after the FormType
object header, and the various strings are all tacked on after the
structure for the object the belong to. A form in memory is a single
chunk of memory holding all these things appended together.
> I'm having trouble understanding weather these other created items
> are pointed to, or weather they are part of the resource DB record
> (serial).
Yes, both; you navigate through a FormType structure by following
pointers, but everything pointed to is in one big memory chunk.
But an exception to this is if you change the text of an object (like a
control) by setting it to point to some string elsewhere in memory. If
this is the case for your form, then the task of saving the whole
shebang as a 'tFRM' would get much more complicated.
Let me ask -- what are you trying to accomplish here?
-slj-