delphi中使用自定义资源的方法

如果要在delphi中使用自定义资源文件*.res文件,比如一个光标,此时可以采用下列步骤:

1,创建包含相应的资源文件,这里是创建一个包含自定义光标的res文件。

2,在主窗体的pas文件中加入编译指令,要求编译器将资源文件链接到最终文件中。

3,在FormCreate的时候加载资源并使用。

 unit Unit1;

 interface

 uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs; type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end; var
Form1: TForm1; //加入编译指令
{$R custom.res}
implementation {$R *.dfm} procedure TForm1.FormCreate(Sender: TObject);
begin
Screen.Cursors[] := LoadCursor(hInstance, 'TEST');
Form1.Cursor := ;
end; end.
上一篇:2017/10/10 jar包错误


下一篇:PAT 1083 是否存在相等的差 (20 分)