Marco Web Center

[an error occurred while processing this directive]

Home: Code Repository: Delphi 2009 Handbook

Project: ResourceTest.dproj

Project Structure

ResourceTest.dpr
program ResourceTest;

{$R *.dres}

uses
  Forms,
  ResourceTest_MainForm in 'ResourceTest_MainForm.pas' {FormResourceTest};

{$R *.res}

begin
  Application.Initialize;
  Application.MainFormOnTaskbar := True;
  Application.CreateForm(TFormResourceTest, FormResourceTest);
  Application.Run;
end.
ResourceTest_MainForm.pas
unit ResourceTest_MainForm;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls;

type
  TFormResourceTest = class(TForm)
    Image1: TImage;
    btnIcon: TButton;
    btnGif: TButton;
    btnResString: TButton;
    procedure btnIconClick(Sender: TObject);
    procedure btnGifClick(Sender: TObject);
    procedure btnResStringClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  FormResourceTest: TFormResourceTest;

implementation

{$R *.dfm}

procedure TFormResourceTest.btnGifClick(Sender: TObject);
begin
  Image1.Picture.Bitmap.LoadFromResourceName(hInstance, 'Bitmap_Shipping');
end;

procedure TFormResourceTest.btnIconClick(Sender: TObject);
begin
  Icon.LoadFromResourceName(hInstance, 'Icon_Factory');
  Application.Icon.LoadFromResourceName(hInstance, 'Icon_Factory');
end;

resourcestring
  strFolder = 'C:\Users';

procedure TFormResourceTest.btnResStringClick(Sender: TObject);
begin
  // just to prove it keeps working
  ShowMessage (strFolder);
end;

end.
ResourceTest_MainForm.pas.dfm
object FormResourceTest: TFormResourceTest
  Left = 0
  Top = 0
  Caption = 'ResourceTest'
  ClientHeight = 289
  ClientWidth = 440
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'Tahoma'
  Font.Style = []
  OldCreateOrder = False
  DesignSize = (
    440
    289)
  PixelsPerInch = 96
  TextHeight = 13
  object Image1: TImage
    Left = 40
    Top = 56
    Width = 359
    Height = 198
    Anchors = [akLeft, akTop, akRight, akBottom]
    ExplicitWidth = 473
    ExplicitHeight = 201
  end
  object btnIcon: TButton
    Left = 40
    Top = 16
    Width = 75
    Height = 25
    Caption = 'btnIcon'
    TabOrder = 0
    OnClick = btnIconClick
  end
  object btnGif: TButton
    Left = 128
    Top = 16
    Width = 75
    Height = 25
    Caption = 'btnBmp'
    TabOrder = 1
    OnClick = btnGifClick
  end
  object btnResString: TButton
    Left = 216
    Top = 16
    Width = 89
    Height = 25
    Caption = 'btnResString'
    TabOrder = 2
    OnClick = btnResStringClick
  end
end
FACTORY.ICO
SHIPPING.BMP
BMö¬
HTML file generated by PasToWeb, a tool by Marco Cantù
Copyright 2008 Marco Cantù