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 行の反復コードを意味します。これを最適化する方法はありますか?
また、そのコード ブロックを別の手順 (同じユニット内) に配置しようとしました。しかし、Delphiはそれsender
が宣言されていないと私に言います。