简便的方法:
其实可以简化问题用TScreen对象的功能就可以了: Screen.Cursor:=crHandPoint;
--------------------------------------------------------
较复杂的方式 使用API函数 和消息
用SetCursor要拦截WM_SETCURSOR以下是一个例子: unit Unit1;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, BtnEdit, Buttons;
type TForm1 = class(TForm) BtnEdit1: TBtnEdit; BtnEdit2: TBtnEdit; Edit1: TEdit; SpeedButton1: TSpeedButton; procedure SpeedButton1Click(Sender: TObject); private { Private declarations } ChangeCursor:boolean; procedure WMSetCursor(var Msg:TMessage);message WM_SETCURSOR; public { Public declarations } end;
var Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.SpeedButton1Click(Sender: TObject); begin ChangeCursor:=Not ChangeCursor; end;
procedure TForm1.WMSetCursor(var Msg: TMessage); begin if ChangeCursor then SetCursor(LoadCursor(0,IDC_HAND)) else inherited; end;
end.
|
请发表评论