rt
//直接加载.ico文件为鼠标光标
const
crMyCursor = 1; //自定义光标号,一般为正数以免和系统定义的冲突
var
Form1: TForm1;
bOK:boolean;//自定义光标创建否
hMyCursor:HCursor;//自定义光标句柄
implementation
{$R *.dfm}
procedure TForm1.FormDestroy(Sender: TObject);
begin
if bOK then
DestroyCursor(hMyCursor);//释放自定义光标资源
end;
procedure TForm1.Button1Click(Sender: TObject);
var
sFile:string;
begin
if bOK then
DestroyCursor(hMyCursor);//释放自定义光标资源,以更改自定义光标
bOK:=false;
if Opendialog1.execute then
//OpenDialog1.filter:=Cursorfiles|*.cur|Icon files|*.ico
sFile:=OpenDialog1.FileName
else
exit;
hMyCursor:= LoadCursorFromFile(PChar(sFile));
if hMyCursor<>0 then //载入成功
begin
Screen.Cursors[crMyCursor] :=hMyCursor;
Cursor := crMyCursor;
bOK:=true;
end
else
Showmessage(Failure to Create);
end;