可以用消息处理,在想改变鼠标形状是地方向系统发自定义消息,在此消息的处理过程中家上你的代码即可。参考下面的代码:
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
const
SX_MYMESSAGE = WM_USER + 100;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
procedure SXMyMessage(var Msg: TMessage);message SX_MYMESSAGE;
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.DFM}procedure TForm1.Button1Click(Sender: TObject);begin
SendMessage(Handle,SX_MYMESSAGE,0,0);
end;procedure TForm1.SXMyMessage(var Msg: TMessage);
begin
Cursor := -11;
end;end.
用Enter键激活Button1
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
const
SX_MYMESSAGE = WM_USER + 100;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
procedure SXMyMessage(var Msg: TMessage);message SX_MYMESSAGE;
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.DFM}procedure TForm1.Button1Click(Sender: TObject);begin
SendMessage(Handle,SX_MYMESSAGE,0,0);
end;procedure TForm1.SXMyMessage(var Msg: TMessage);
begin
Cursor := -11;
end;end.
用Enter键激活Button1
解决方案 »
- D7设置问题,按F9运行怎么只出来CPU调试窗口,不出来程序啊?
- 字符串送分题。。
- 软件启动时就访问远程sql server,并检查连通了sql server没有?
- 有关自动填表的问题,如果网页中是Checkbox,和Select如何让checkbox取消选择,Select选择第二项?
- 大家看看这个错误是什么原因,谢。
- 求助!!!
- stringgrid的每一个列宽有没有办法动态生成一个固定值????--------------100分拿去!!!
- 如何获得Oracle的登录密码?
- Delphi里有没有类似于c里面的memcpy一样的函数?
- 这里有很多Delphi6的控件!
- 请问各位高手,可用分如何获得?
- 学DELPHI有用吗?我好像发现去考程序员时没有DELPHI这一项啊!?
SendMessage(Handle,SX_MYMESSAGE,0,0);
这样就可以不用移动鼠标就触发改变形状的事件
p:TPoint;
begin
MyControl.Cursor:=MyCursor;
GetCursorPos(p);
SetCursorPos(p.X,p.Y);