关于资源文件的一个例子~在线等候。。。(100M)(100分)

  • 主题发起人 Delphids
  • 开始时间
D

Delphids

Unregistered / Unconfirmed
GUEST, unregistred user!
在delphi中引用一个鼠标图标的资源文件,将程序运行起来以后,鼠标应该将变成我
在资源文件中画的样子,但是没有实现,请大家帮忙看看程序,问题出在哪里,谢谢!!

unit Unit1;

interface

{$R face.res}

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Menus;

type
TForm1 = class(TForm)
PopupMenu1: TPopupMenu;
procedure FormCreate(Sender: TObject);
procedure FormClick(Sender: TObject);
procedure FormKeyDown(Sender: TObject
var Key: Word;
Shift: TShiftState);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.FormCreate(Sender: TObject);
begin
screen.cursors[1]:=LoadCursor(hInstance,pChar('Cursor1'));
screen.cursors[2]:=LoadCursor(hInstance,pChar('Cursor2'));
screen.Cursors[3]:=LoadCursor(hInstance,pChar('Cursor3'));
screen.cursors[4]:=LoadCursor(hInstance,pChar('Cursor4'));
screen.cursors[5]:=LoadCursor(hInstance,pChar('Cursor5'));
screen.cursor:=screen.Cursors[3];
end;

procedure TForm1.FormClick(Sender: TObject);
begin
screen.cursor:=screen.Cursors[1];
screen.cursor:=screen.Cursors[3];
screen.cursor:=screen.Cursors[2];
screen.cursor:=screen.Cursors[3];
screen.cursor:=screen.Cursors[4];
screen.cursor:=screen.Cursors[3];
screen.cursor:=screen.Cursors[5];
end;

procedure TForm1.FormKeyDown(Sender: TObject
var Key: Word;
Shift: TShiftState);
begin
if key = 13 then
begin
screen.Cursor := screen.Cursors[4];
screen.Cursor := screen.Cursors[3];
end;

if key = 44 then
begin
screen.Cursor := screen.Cursors[5];
screen.Cursor := screen.Cursors[3];
end;
end


end.
 
const
crMyCursor = 1
// 宣告一个常数
procedure TForm1.FormCreate(Sender: TObject);
begin
Screen.Cursors[crMyCursor] := LoadCursor(hInstance,'CURSOR_1');
Cursor := crMyCursor;//指定 form1 的 cursor 为自订鼠标
Button1.Cursor := crMyCursor;//指定Button1的cursor为自订鼠标
end;

将 screen.cursor:=... 改为 Cursor:=... 试一试?
 
screen.cursor:=1
 
谢谢 creation-zy 和 redcony 的回答
可是问题还是没有解决
 
如果假设程序没有问题,那么是不是资源文件的问题?
我是用delphi5自带的Image Editor新建的资源文件face.res
然后在里面画了那5个Cursor的
 
加上#pragram resource "aa.res"
 
在uses上加上{$R aa.res}
 
谢谢大家,分分
 
顶部