掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
コンポーネントでParentFontを対応するには? (ID:22772)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
TComponent から派生させたコンポーネントを作成しています。 ParentFontプロパティをTrueにしている場合に MyFormの親フォーム(メインフォーム)のフォントが変更されたときに MyFormのフォントも変更したいのですが、どうすればよいのでしょうか? 以下、フォントに関する部分以外を省略して 関係のある部分だけを抜き出してみました。 TMyComponent = class(TComponent) private MyForm: TForm; FParentFont: Boolean; protected procedure SetFont(Value: TFont); public constructor Create(AOwner: TComponent); override; destructor Destroy; override; published property Font: TFont read FFont write SetFont; property ParentFont: Boolean read FParentFont write FParentFont; end; constructor TMyComponent.Create(AOwner: TComponent); begin inherited Create(AOwner); MyForm := TForm.CreateNew(Application.MainForm); MyForm.Parent := Application.MainForm; // フォームのフォント FFont := TFont.Create; end; destructor TOriginalDialogForms.Destroy; begin FFont.Free; MyForm.Free; inherited Destroy; end; procedure TMyComponent.SetFont(Value: TFont); begin if Value <> FFont then begin FFont.assign(Value); end; end;
←解決時は質問者本人がここをチェックしてください。
更新する
戻る
掲示板システム
Copyright 2021 Takeshi Okamoto All Rights Reserved.