RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
TBitmap.LoadFromResourceName Method

Loads a bitmap resource into the bitmap object.

Pascal
procedure LoadFromResourceName(Instance: THandle; const ResName: String);
C++
__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.

Note: Use this routine to load bitmaps from RES files instead of the LoadBitmap API. LoadBitmap does not support 256-color images.
 

C++ Examples: 

 

/*
This example requires a resource file in the sources directory.
*/

#pragma resource "extrares.res"

void __fastcall TForm1::Button1Click(TObject *Sender)
{
  Graphics::TBitmap *Bitmap1 = new Graphics::TBitmap();
  try
  {
    Bitmap1->LoadFromResourceName((int)HInstance, "Live");
    Canvas->Draw(12,12,Bitmap1);
  }
  catch (...)
  {
    MessageBeep(0);
  }
  delete Bitmap1;
}

 

Delphi Examples: 

{
LoadFromResourceName example
}

{$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);
  finally
    BitMap1.Free;
  end;
end;

 

LoadFromResourceID 

HInstance

Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!