2つのコンポーネントAとBがあります。コンポーネントBはコンポーネントAから派生し、ほとんどのプロパティと手順をコンポーネントAと共有しています。今、私はこのような長い手順を持っています:
procedure DoSomething;
begin
Form1.Caption := Component_A.Caption;
// hundreds of additional lines of code calling component A
end;
コンポーネントBがアクティブであるかどうかに応じて、上記の手順を再利用し、Component_AパーツをコンポーネントBの名前に置き換えます。次のようになります。
procedure DoSomething;
var
C: TheComponentThatIsActive;
begin
if Component_A.Active then
C := Component_A;
if Component_B.Active then
C := Component_B;
Form1.Caption := C.Caption;
end;
Delphi2007でそれを行うにはどうすればよいですか?
ありがとう!