首先,在Delphi的主菜单工具下选图像编辑器,编辑一个名为face.res的资源文件,它应该包括个人制作的五个.cur文件:faceleft.cur(图为:圆脸上一双向左看的眼睛),faceright.cur(图为:圆脸上一双向右看的眼睛),plainface.cur(图为:圆脸上一双向前看的眼睛),leftshrink.cur(图为:闭着左眼的圆脸),rightshrink.cur(图为:闭着右眼的圆脸)。 做好资源文件后,打开一个新的窗体FORM1并放置PopupMenu组件,把FORM1的属性PopupMenu置为PopupMenu1。然后在UNIT1的INTERFACE段下加入以下代码: {$ R face.res} 并在TForm1.FormCreate事件内加入以下代码: screen.cursors[1]:=LoadCursor(hInstance, pChar(′lfaceleft′)); screen.cursors[2]:=LoadCursor(hInstance, pChar(′faceright′)); screen.cursors[3]:=LoadCursor(hInstance, pChar(′plainface′)); screen.cursors[4]:=LoadCursor(hInstance, pChar(′leftshrink′)); screen.cursors[5]:=LoadCursor(hInstance, pChar(′rightshrink′)); screen.cursor:=plainface; 在TForm1.FormClick事件内加入以下代码: screen.cursor:=faceleft; screen.cursor:=plainface; 在TForm1.FormKeyDown事件内加入以下代码: if button=MbLeft then begin screen.cursor:=leftshrink; screen.cursor:=plainface; end; if button=MbRight then begin screen.cursor:=rightshrink; screen.cursor:=plainface; end;
??.rc 文件写入 hand CURSOR hand.cur主程序写入 Screen.Cursors[crHandPoint]:=LoadCursor(hinstance,'hand');//改变手的光标选择加一个文件 进工程(add a file project) 出现文件打开对话筐,选择*.rc加进去就可以了也可以手在工程文件里添加{$R '目录\hand.res' '目录\hand.rc'}其他替换已此类推…… 好运
LoadCursor
SetCursor
不过记得最后要恢复Cursor,否则会很难看的
给点代码不胜感激!
做好资源文件后,打开一个新的窗体FORM1并放置PopupMenu组件,把FORM1的属性PopupMenu置为PopupMenu1。然后在UNIT1的INTERFACE段下加入以下代码:
{$ R face.res}
并在TForm1.FormCreate事件内加入以下代码:
screen.cursors[1]:=LoadCursor(hInstance,
pChar(′lfaceleft′));
screen.cursors[2]:=LoadCursor(hInstance,
pChar(′faceright′));
screen.cursors[3]:=LoadCursor(hInstance,
pChar(′plainface′));
screen.cursors[4]:=LoadCursor(hInstance,
pChar(′leftshrink′));
screen.cursors[5]:=LoadCursor(hInstance,
pChar(′rightshrink′));
screen.cursor:=plainface; 在TForm1.FormClick事件内加入以下代码:
screen.cursor:=faceleft;
screen.cursor:=plainface; 在TForm1.FormKeyDown事件内加入以下代码:
if button=MbLeft then
begin
screen.cursor:=leftshrink;
screen.cursor:=plainface;
end;
if button=MbRight then
begin
screen.cursor:=rightshrink;
screen.cursor:=plainface;
end;
hand CURSOR hand.cur主程序写入
Screen.Cursors[crHandPoint]:=LoadCursor(hinstance,'hand');//改变手的光标选择加一个文件 进工程(add a file project) 出现文件打开对话筐,选择*.rc加进去就可以了也可以手在工程文件里添加{$R '目录\hand.res' '目录\hand.rc'}其他替换已此类推…… 好运
加入{$R *.res}
假如你的指针名为crhehe
const
crhehe:=1;
buttonclick
screen.Cursors[crhehe]:=loadcursor(Hinstance,'CUR');
screen.Cursor:=crhehe;
加载成功.
不过自己做指针麻烦呀
{ Copyright © 1999 by Delphi 5 Developer's Guide - Xavier Pacheco and Steve Teixeira }unit MainFrm;interfaceuses
SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
Forms, Dialogs, StdCtrls;
const
crCrosshair = 1;type
TMainForm = class(TForm)
btnChangeCursor: TButton;
procedure btnChangeCursorClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
MainForm: TMainForm;implementation{$R *.DFM}procedure TMainForm.btnChangeCursorClick(Sender: TObject);
var
HC: HCursor; //Êý¾ÝÀàÐͶøÒÑ
begin
HC := LoadCursor (hInstance, 'CROSShair'); // Load the cursor
Screen.Cursors[crCrosshair] := HC; // Add this cursor to the Cursors array
Screen.Cursor := crCrosshair; //Now change the screen's cursor to the new cursor
end;end.{
Copyright © 1999 by Delphi 5 Developer's Guide - Xavier Pacheco and Steve Teixeira
}program CrossHair;uses
Forms,
MainFrm in 'MainFrm.pas' {MainForm};{$R *.RES}
{$R Crosshairres.RES}begin
Application.CreateForm(TMainForm, MainForm);
Application.Run;
end.
或者自己做RC编译成RES也可以用呀!