在MouseMove判断下坐标,不过有个灵敏度,移动快了就反映不过来,可以缩小坐标范围 procedure TForm1.BitBtn1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); begin if(x>0) and (x<BitBtn1.Width-1) and (y>0) and (y<BitBtn1.Height-1) then BitBtn1.Font.Color:=clRed; else BitBtn1.Font.Color:=clBlack; end;
我又这样改了一下: procedure TForm1.MouseLeave(var Msg:TMessage); begin if TObject(Msg.LParam) is TBitBtn then begin TBitBtn(Msg.LParam).Font.Color:=clBlack; RadioGroup1.Visible:=false;//密码
我有8个按钮,现在采取的办法是在每一个按钮的onMouseMove中显示一个,屏蔽掉其他7个,但这样很麻烦。
我有8个按钮,现在采取的办法是在每一个按钮的onMouseMove中显示一个,屏蔽掉其他7个,但这样很麻烦。
procedure TForm1.BitBtn1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
if(x>0) and (x<BitBtn1.Width-1) and (y>0) and (y<BitBtn1.Height-1) then
BitBtn1.Font.Color:=clRed;
else
BitBtn1.Font.Color:=clBlack;
end;
delphi自带的控件XPman控件,在win32里有个XPman把它放在窗体上,就可以了。(D7)
procedure MouseLeave(var Msg:TMessage); Message CM_MouseLeave;procedure TForm1.MouseLeave(var Msg:TMessage);
begin
if TObject(Msg.LParam) is TBitBtn then
TBitBtn(Msg.LParam).Font.Color:=clBlack;
end;procedure TForm1.BitBtn1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
TBitBtn(Sender).Font.Color:=clRed;
end;
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons;type
TFrmMain = class(TForm)
Button1: TButton;
Button2: TButton;
BitBtn1: TBitBtn;
procedure Button1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure BitBtn1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
private
procedure MouseLeave(var Msg:TMessage); Message CM_MouseLeave;
{ Private declarations }
public
{ Public declarations }
end;var
FrmMain: TFrmMain;
implementation{$R *.dfm}procedure TFrmMain.BitBtn1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
TBitBtn(Sender).Font.Color:=clRed; //有效
end;procedure TFrmMain.Button1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
TButton(Sender).Font.Color:=clRed; //无效
end;procedure TFrmMain.MouseLeave(var Msg:TMessage);
begin
if TObject(Msg.LParam) is TButton then
TButton(Msg.LParam).Font.Color:=clBlack;
end;
end.
因为在字体变红的同时要有个TRadioGroup控件要显示,我就比葫芦画瓢在
TBitBtn(Msg.LParam).Font.Color:=clBlack;
下面添了一句:
TRadioGroup(Msg.LParam).Visible:=false;
可执行后连bitbtn控件也不正常显示了,请问各位老师,我应怎样改?
procedure TForm1.MouseLeave(var Msg:TMessage);
begin
if TObject(Msg.LParam) is TBitBtn then begin
TBitBtn(Msg.LParam).Font.Color:=clBlack;
RadioGroup1.Visible:=false;//密码
RadioGroup8.Visible:=false;//物品查阅
end;
end;
再加上BitBtn1MouseMove事件调用,问题已完全解决。
谢谢各位老师