掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
処理を共通化するには? (ID:24841)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
THogeForm=Class(TForm) public Procedure SetLabel(aCaption: String); virtual; abstract; end; 各フォームの継承元を TForm から THogeForm に変更 ソースコード上で、直接書き換え TForm2=Class(THogeForm) public Procedure SetLabel(aCaption: String); override; end; Procedure TForm2.SetLabel(aCaption: String); begin //Form2では、TLabelに表示 Label1.Caption := aCaption; end; TForm3=Class(THogeForm) public Procedure SetLabel(aCaption: String); override; end; Procedure TForm3.SetLabel(aCaption: String); begin //Form3では、TEditに表示 Edit1.Text := aCaption; end; これでMDIChildがTHogeFormを継承したものであれば、いかの一行で済みます。 (Screen.ActiveForm as THogeForm).SetLabel('Hello World'); いかがかな?
←解決時は質問者本人がここをチェックしてください。
更新する
戻る
掲示板システム
Copyright 2021 Takeshi Okamoto All Rights Reserved.