这是TPanel
当鼠标光标悬停在它上面时“动画”的代码。我也有一个代码块来取消它的动画。
procedure Tmain.pStarting1MouseEnter(Sender: TObject);
begin
if sender = pStarting1 then pStarting1.BevelInner := bvLowered;
if sender = pStarting2 then pStarting2.BevelInner := bvLowered;
if sender = pStarting3 then pStarting3.BevelInner := bvLowered;
if sender = pStarting4 then pStarting4.BevelInner := bvLowered;
if sender = pStarting5 then pStarting5.BevelInner := bvLowered;
if sender = pStarting6 then pStarting6.BevelInner := bvLowered;
if sender = pStarting7 then pStarting7.BevelInner := bvLowered;
if sender = pStarting8 then pStarting8.BevelInner := bvLowered;
if sender = pStarting9 then pStarting9.BevelInner := bvLowered;
end;
正如你所看到的,它非常重复,因为我还有另外 27TPanel
秒的动画,这意味着另外 27 行重复的代码。那么有没有办法可以优化呢?
我也尝试过将该代码块放入一个单独的过程中(在同一个单元中)。但德尔福告诉我这sender
是未声明的。