Главная страница | назад





Article #17613: Adding bitmaps in a builder project w/o using a TImage

 Question and Answer Database
FAQ2613C.txt Adding bitmaps in a builder project w/o using a TImage
Category :IDE
Platform :All
Product :C++Builder 3.x
Question:
I want to add a bitmap in my project as a resource instead of as
a design time TImage component.
Answer:
Open the Image editor
Create a new Resource file (.res)
Create a new bitmap named Bitmap1 (default) in that .res file
Save the .res file to your project folder with a name that
is not the same as the project's default .res file.
In CBuilder's main menu Click:
Project | Add To Project
Find your .res file an choose OK.
In the .h file declare a Graphics::TBitmap pointer:
private:
Graphics::TBitmap* MyBitmap;
in the .cpp file create a TBitmap Object
void __fastcall TForm1::FormCreate(TObject *Sender)
{
MyBitmap = new Graphics::TBitmap();
MyBitmap->LoadFromResourceName((int)HInstance, "Bitmap1");
}
7/2/98 10:32:32 AM

Last Modified: 01-SEP-99