Thanks for all your help. Here's what I did:
I created a resource database with the resource for that form in it (error
checking removed):
UInt attr;
UInt numRes = 0;
// set resDb flag to
true
Err err = DmCreateDatabase (0, dbName, creator, type, true);
LocalID dbId = DmFindDatabase(0, dbName);
DmOpenRef resDB = DmOpenDatabase(0, dbId, dmModeReadWrite);
VoidHand res = DmGetResource (frmRes, frmID);
err = DmAttachResource(resDB, res, frmRes, frmID);
numRes = DmNumResources(resDB); // debugging
err = DmCloseDatabase(resDB);
// Get the attributes and set the backup bit.
err = DmDatabaseInfo( 0, dbId, NULL, &attr, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL );
if (!err)
{
attr |= dmHdrAttrBackup;
DmSetDatabaseInfo( 0, dbId, NULL, &attr, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL );
}
Then from the library I just opened the database and called FrmInitForm:
FormPtr modalFrm = NULL;
DmOpenRef resDB = DmOpenDatabaseByTypeCreator ('rsdb', 'JSAE',
dmModeReadOnly);
ErrFatalDisplayIf(!resDB, "Couldn't load lib");
modalFrm = FrmInitForm(frmID);
Then close the resDB when all done. Works like a charm.
Thanks,
Kevin
> -----Original Message-----
> From: Kevin O'Keefe
> Sent: Thursday, July 22, 1999 10:55 AM
> To: '[EMAIL PROTECTED]'
> Subject: UI From Shared Library
>
>
> I want to put up a fairly simple form from a shared library.
> The form is
> simple enough to be drawn dynamically if need be, but I'm
> lazy and want to
> use resources if it is at all possible. Though I was pretty
> certain I would
> not be able to do it, I tried some experiments to see how far
> I could get.
>
> Here is what I tried:
> I created the resource and put it into my shared library
> project. It builds
> and links in just fine. Then in the library I did a
> FrmGotoForm giving it
> the id of my form in the shared library resource. Well, a
> form came up, but
> it wasn't the right one (I had mistakenly given the form in
> the library the
> same id as a form in the application, so that form was loaded
> but associated
> with the wrong form handler and init code). I quickly
> realized my error and
> gave the form a unique ID, and tried the FrmGotoForm again.
> This time it
> completely fails because it does not find the resource.
>
> I am guessing that the library's resources do not get linked into the
> application resource chain, so it doesn't find it. My
> question is: Is there
> a way to get the library's resources linked into the
> application's resource
> chain. Will it work if I can get that resource loaded?
>
> Thanks in advance,
> Kevin
>
> ____________________________
> Kevin O'Keefe
> The Windward Group
> A Metamor Software Solutions Company
> TEL: (408) 399-8577
> FAX: (408) 395-9642
>
>
>