clkPan[I]是自定义的23个panel控件,想实现的功能:当鼠标进入任意一个clkPan控件时光标变成小手形状,退出该panel时恢复默认形状。下面是我的代码,不知道错在哪?高手帮忙看看,谢谢。
procedure TParaAddForm.CMMouseEnter(var Msg: TMessage);
var
I:Integer;
begin
//**************获取鼠标刚进入的控件类型************//
sObject:=TObject(Msg.LParam);
if sObject is TPanel then
if sObject <> nil then
for I:=1 to 23 do
if sObject=clkPan[I] then
begin
clkPan[I].Cursor:=crHandPoint;
end;
end;procedure TParaAddForm.CMMouseLeave(var Msg: TMessage);
var
I: Integer;
begin
//********获取鼠标刚离开的控件类型*********//
sObject:=TObject(Msg.LParam);
if sObject is TPanel then
if sObject <> nil then
for I:=1 to 23 do
if sObject=clkPan[I] then
begin
clkPan[I].Cursor:=crDefault;
end;
end;
procedure TParaAddForm.CMMouseEnter(var Msg: TMessage);
var
I:Integer;
begin
//**************获取鼠标刚进入的控件类型************//
sObject:=TObject(Msg.LParam);
if sObject is TPanel then
if sObject <> nil then
for I:=1 to 23 do
if sObject=clkPan[I] then
begin
clkPan[I].Cursor:=crHandPoint;
end;
end;procedure TParaAddForm.CMMouseLeave(var Msg: TMessage);
var
I: Integer;
begin
//********获取鼠标刚离开的控件类型*********//
sObject:=TObject(Msg.LParam);
if sObject is TPanel then
if sObject <> nil then
for I:=1 to 23 do
if sObject=clkPan[I] then
begin
clkPan[I].Cursor:=crDefault;
end;
end;
http://expert.csdn.net/Expert/topic/2601/2601363.xml?temp=.9008905
Y: Integer);
begin
TPanel(sender).Cursor:= crHandPoint;
end;再将所有clkPan[I] 中的OnMouseMove:= _PanelMouseMove;
procedure TForm1._PanelMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
TPanel(sender).Cursor:= crHandPoint;
end;再将所有clkPan[I] 中的OnMouseMove:= _PanelMouseMove;
应该是可以的