掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
グラフィックコントロールの問題 (ID:17227)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
質問です。次のようなコードを書き、TSampleControl をフォームに貼り付けると、実行終了時に EPrivilege 例外が発生してしまいます。 どこがいけないのかご教授いただけないでしょうか? unit cmp; interface uses Controls, Classes; type TChildControl = class(TGraphicControl) protected procedure Paint; override; end; TSampleControl = class(TGraphicControl) protected FChildControl: TChildControl; procedure Paint; override; procedure SetParent(AParent: TWinControl); override; procedure SetChildControl(Value: TChildControl); public constructor Create(AOwner: TComponent); override; published property ChildControl: TChildControl read FChildControl write SetChildControl; end; TBaseControl = class(TWinControl) private FSampleControl: TSampleControl; procedure SetSampleControl(Value: TSampleControl); public constructor Create(AOwner: TComponent); override; published property SampleControl: TSampleControl read FSampleControl write SetSampleControl; end; procedure Register; implementation procedure Register; begin RegisterComponents('sample', [TBaseControl]); end; procedure TChildControl.Paint; begin inherited; Canvas.Rectangle(ClientRect); end; constructor TSampleControl.Create(AOwner: TComponent); begin inherited; FChildControl:= TChildControl.Create(Self); FChildControl.Name:= 'ChildControl'; FChildControl.Width:= 100; FChildControl.Height:= 100; end; procedure TSampleControl.Paint; begin inherited; Canvas.Rectangle(ClientRect); end; procedure TSampleControl.SetParent(AParent: TWinControl); begin inherited; if Assigned(FChildControl) then begin FChildControl.Parent:= AParent; FChildControl.Visible:= True; end; end; procedure TSampleControl.SetChildControl(Value: TChildControl); begin FChildControl:= Value; end; end.
←解決時は質問者本人がここをチェックしてください。
戻る
掲示板システム
Copyright 2020 Takeshi Okamoto All Rights Reserved.