Just get the size of the resource, allocate a new resource in your new database 
(DmNewResource) and then copy the resource memory into the new resource.

To use this resource, you will have to open your new resource database so it gets into 
the resource chain.  Also, when you create the new resource, you'll probably want to 
create it with a unique ID (at least different from what you have in your source 
resource database) so that it does not conflict with the original.  You'll have to 
rewrite the code that uses it to use this new unique identifier.

Kevin

-----Original Message-----
From: Matthew Bevan [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, December 17, 2002 10:45 PM
To: Palm Developer Forum
Subject: Copying a resource...


I'm trying to copy a resource from my main application into a sattelite file, 
that way I can leave the new file open without needing to worry about 
conflicts with the rest of my resources (it's bad when you try to hotsync and 
it opens a window from my app ;)

What's the best way to do this?  What I currently have apparently removes the 
resource from existence.

  DmOpenRef            appRsrc, iconRsrc;
  SleepEventParamType *data;
  Err                  error;
  MemHandle            CommandBarIconH;

01  FtrGet ( appCreator, 2048, (UInt32 *)&iconRsrc );
02  if ( iconRsrc ) DmCloseDatabase(appRsrc);
03  error = DmCreateDatabase(0, "QBSharedIcons", appCreator,
        iconDbType, true);
04  iconRsrc = DmOpenDatabaseByTypeCreator (
        iconDbType, appCreator, dmModeReadOnly );
05  if ( !error ) {
06    CommandBarIconH = DmGetResource ( bitmapRsc, BarBackupAllBitmap );
07    DmAttachResource (
          iconRsrc, CommandBarIconH, bitmapRsc, BarBackupAllBitmap+3 );
08  }
09  FtrSet ( appCreator, 2048, (UInt32)iconRsrc );

 - Lines 1 and 2 check for the existance of an already open icon database.
 - Line 3 creates a new icon database.  Yes, I don't check to see if the file 
   exists because the OS already does ;)
 - Line 4 opens either the newly created database, or the previous one.
 - Line 5 checks to see if the database was created.
 - If the database was created, line 6 gets a handle to the bitmap in my 
   application.  Line 7 attempts to attach that handle to the new database.  
   Can you not have one handle in multiple databases?  It'd be spiffy, but I 
   could see why they wouldn't like me to do this...
 - Line 9 copies the pointer to the open resource file so I can check later.

Ideas, anyone?
        Matthew Bevan


-- 
Matthew (Darkstorm) Bevan       [EMAIL PROTECTED]
Margin Software, NECTI.         http://www.marginsoftware.com
        Re-inventing the wheel, every time.

 - Stay away from hurricanes for a while.


-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/support/forums/


------------------------------------------

The information in this transmittal and any attachments is privileged and confidential 
and is intended only for the recipient(s) listed above. You are hereby notified that 
any unauthorized distribution or copying of this transmittal or its attachments is 
prohibited. If you have received this transmittal in error, please notify Invivodata 
immediately at (831) 438-9550.

------------------------------------------


--
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/support/forums/

Reply via email to