掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
動的フレームの再作成でエラー (ID:22552)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
これを読まれているみなさんへ実際どのような時に エラーが起きるのか、確認してもらう為に 簡単なサンプルを載せておきます。 処理内容: ToolBarのToolButtonをクリックしたタイミングで 別フォームからFreeAndNilをします。 この時、VCLがPostMessageを発行しているので エラーが発生します。 -------------------------------------------------------------------------------- unit Unit1; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) Button1: TButton; procedure Button1Click(Sender: TObject); private { Private 宣言 } procedure Form2Free(); public { Public 宣言 } end; var Form1: TForm1; implementation uses Unit2; {$R *.DFM} procedure TForm1.Button1Click(Sender: TObject); begin Form2 := TForm2.CreateAndSetEvent(Self, Form1.Form2Free); end; procedure TForm1.Form2Free; begin FreeAndNil(Form2); end; end. -------------------------------------------------------------------------------- unit Unit2; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ComCtrls, ToolWin; type TForm2FreeEvent = procedure() of object; TForm2 = class(TForm) ToolBar1: TToolBar; ToolButton1: TToolButton; procedure ToolButton1Click(Sender: TObject); private { Private 宣言 } FormFree: TForm2FreeEvent; public { Public 宣言 } constructor CreateAndSetEvent(AOwner: TComponent;FreeEvent: TForm2FreeEvent); end; var Form2: TForm2; implementation {$R *.DFM} { TForm2 } { TForm2 } constructor TForm2.CreateAndSetEvent(AOwner: TComponent; FreeEvent: TForm2FreeEvent); begin inherited Create(AOwner); FormFree := FreeEvent; Show; end; procedure TForm2.ToolButton1Click(Sender: TObject); begin FormFree(); end; end.
←解決時は質問者本人がここをチェックしてください。
更新する
戻る
掲示板システム
Copyright 2021 Takeshi Okamoto All Rights Reserved.