|

楼主 |
发表于 2009-8-28 17:22:45
|
显示全部楼层
所有控件调用下面这个
procedure TMainForm.SpeedButton21MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
Var
i:Integer;
begin
TSpeedButton(Sender).Flat:=False;
with pnlDesktopTreeView do
begin
for i:=0 to ControlCount-1 do
begin
if Controls is TSpeedButton then //用is来判断类型
if TSpeedButton(Sender).Name<>TSpeedButton(Controls).Name then
TSpeedButton(Controls).Flat:=True;
end;
end;
end;
在它的容器上也写上
procedure TMainForm.pnlDesktopTreeViewMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
Var
i:Integer;
begin
with pnlDesktopTreeView do
begin
for i:=0 to ControlCount-1 do
begin
if Controls is TSpeedButton then //用is来判断类型
TSpeedButton(Controls).Flat:=True;
end;
end;
end;
:confused: 感觉有点笨拙
其实我想试下重载不要它写的MouseMove事件,但不会写
TSpeedButton = class(TGraphicControl)
protected
procedure MouseDown(Button: TMouseButton; Shift: Business.System.TShiftState; X: Longint; Y: Longint); override;
public
end;
procedure TSpeedButton .MouseDown(Button: TMouseButton; Shift: Business.System.TShiftState; X: Longint; Y: Longint);
begin
//
end;
但一运行就出错,请问怎么改 |
|