BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

ImageList to .RES

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (VCL Components Usage)
View previous topic :: View next topic  
Author Message
LarryJ
Guest





PostPosted: Wed Mar 23, 2005 9:54 pm    Post subject: ImageList to .RES Reply with quote



Is there a way to automatically save the contents of an ImageList into a new
..RES file?

Thanks
Larry.


Back to top
JD
Guest





PostPosted: Thu Mar 24, 2005 2:11 am    Post subject: Re: ImageList to .RES Reply with quote




"LarryJ" <LarryJ33 (AT) ev1 (DOT) net> wrote:
Quote:

Is there a way to automatically save the contents of an
ImageList into a new .RES file?

No. BCB creates (and recreates) the default .res file
automatically and has no other support for .res files
past that.

However, BCB also comes with 2 other programs that you can use
to create .res files. One is the Image Editor (click Tools |
Image Editor). With the Image Editor, you can create and/or
edit .res files but only in a limited fashion. For example,
you can only manipulate images (bitmaps and cursors) and the
names of said items and images are limited by color variations.

If you use the resource compiler, you can create any number
of .res files that contain any type of things that you want to
include in your application. Restricting my comments to a
TImageList, you would want to include each image in a res file
and load the image list at run time.

The resource compiler expects an asci file with the extension
of .rc. It's also common to use a resource header file with
#define(s) so that that file can also be included into your
source. For example:

// MyResource.rh
#ifndef MyResource_RH
#define MyResource_RH

#define ID_IMAGELIST1 1000 // <-- arbitrary number
#define ID_IMAGELIST2 1001
#define ID_IMAGELIST3 1002

#endif
// end MyResource.rh


// MyResource.rc
#include "MyResource.rh"

ID_IMAGELIST1 BITMAP "FirstImage.bmp"
ID_IMAGELIST2 BITMAP "SecondImage.bmp"
ID_IMAGELIST3 BITMAP "ThirdImage.bmp"
//end MyResource.rc

Just pass the .rc file into the compiler to create a .res file of the same name and tell the compiler that you want to use another .res file:

#include #pragma hdrstop

#include "MainMod.h"
#include "MyResource.rh" //<--- add this
//-------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
#pragma resource "MyResource.res" //<--- add this too
TMainForm *MainForm;

To load an image from the resource, you'll need a TBitmap so you can:

Bitmap1->LoadFromResourceID( (int)HInstance, ID_IMAGELIST1 );

From there you need to get the image into the image list -
which is the only part that I'm unsure of because I've never
done it. The reason is that a .res file is compiled into the
executable just as the TImageList is so it's not very smart to
put an ImageList into a .res file because it serves no purpose
except to make the code more complicated.

Placing it into a resource-only dll is a different issue.
Google for that.

~ JD


Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (VCL Components Usage) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.