LoadFromResourceName (Delphi)

From RAD Studio Code Examples
Jump to: navigation, search

Description

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.

Code

{$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;

Uses