如何覆盖 TPanel 的鼠标向下,以便每次单击面板时它都会改变颜色?我尝试了此代码但无法正常工作:
unit Unit1;
interface
uses
System.SysUtils, System.Classes, Vcl.Controls, Vcl.StdCtrls, Vcl.ExtCtrls,
Vcl.Dialogs;
type
TPanelAA = class(TPanel)
protected
procedure Paint; override;
procedure MouseDown(Button: TMouseButton; Shift: TShiftState;
X, Y: Integer); override;
end;
procedure Register;
implementation
procedure TPanelAA.Paint;
begin
inherited;
Color := $0000FF;
end;
procedure TPanelAA.MouseDown(Button: TMouseButton; Shift: TShiftState;
X, Y: Integer);
begin
ShowMessage('mouse down');
inherited;
Color := $0000FF;
end;
procedure Register;
begin
RegisterComponents('standard', [TPanelAA]);
end;
end.
我不擅长“继承/覆盖”事物。提前致谢