RAD Studio VCL Reference
|
Loads a bitmap resource into the bitmap object.
procedure LoadFromResourceName(Instance: THandle; const ResName: String);
__fastcall LoadFromResourceName(THandle Instance, const AnsiString ResName);
LoadFromResourceName loads the specified bitmap resource along with palette information from a module's executable file.
Instance is the handle of the module that contains the resource.
ResName is the name of the resource to load.
C++ Examples:
/* This example requires a resource file in the sources directory. */ #pragma resource "extrares.res" #include <memory> //for STL auto_ptr class void __fastcall TForm1::Button1Click(TObject *Sender) { std::auto_ptr<Graphics::TBitmap> Bitmap1(new Graphics::TBitmap()); try { Bitmap1->LoadFromResourceName((int)HInstance, "Live"); Canvas->Draw(12,12,Bitmap1.get()); } catch (...) { MessageBeep(0); } }
Delphi Examples:
{ This example demonstrates how to access a resource file. Specify the resource file with the $R directive below. The RC file associated with the resource file relates the resource name with the bitmap. } {$R extrares.res} procedure TForm1.Button1Click(Sender: TObject); var BitMap1 : TBitMap; begin BitMap1 := TBitMap.Create; try BitMap1.LoadFromResourceName(HInstance,'Live'); Canvas.Draw(12,12,BitMap1); BitMap1.LoadFromResourceName(HInstance,'Dead'); Canvas.Draw(12,102,BitMap1); finally BitMap1.Free; end; end;
Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
|
What do you think about this topic? Send feedback!
|