首先编辑 rc 文件如下(假定图片文件放在程序目录下的 img 文件夹下):
bmp1 BITMAP img\bmpFile1.bmp
bmp2 BITMAP img\bmpFile2.bmp

或者:
bmp1,BITMAP,img\bmpFile1.bmp
bmp2,BITMAP,img\bmpFile2.bmp

然后在窗体上添加一个 Image、两个 Button, 代码如下:
unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    Image1: TImage;
    Button1: TButton;
    Button2: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
  Image1.AutoSize := True;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  Image1.Picture.Bitmap.Handle := LoadBitmap(HInstance, 'bmp1');
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  image1.Picture.Bitmap.LoadFromResourceName(HInstance, 'bmp2');
end;

end.

//效果图:
学习使用资源文件[3] - 用 Image 显示资源中的图片

相关文章:

  • 2021-08-25
  • 2021-08-20
  • 2021-12-21
  • 2022-12-23
  • 2022-12-23
  • 2021-10-15
  • 2022-12-23
  • 2022-03-02
猜你喜欢
  • 2021-11-13
  • 2022-02-21
  • 2022-12-23
  • 2021-07-19
  • 2021-08-08
相关资源
相似解决方案