掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
破棄されたフォームを知るには? (ID:32021)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
遅くなり、みなさんすみません。 ・ソース以下3つ(unitMain,unitA,unitB)です。 ・FormA,FormBは自動生成フォームから外しています。 ・ButnAをクリックして、FormAを表示→閉じるし、 ButnChkをクリックするとFalseと表示します。 ・ButnAをクリックして、FormAを表示→閉じるし、 ButnBをクリックして、FormBを表示し、 ButnChkをクリックするとTrueと表示します。 unit unitMain; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TFormMain = class(TForm) ButnA: TButton; ButnB: TButton; ButnChk: TButton; procedure ButnAClick(Sender: TObject); procedure ButnBClick(Sender: TObject); procedure ButnChkClick(Sender: TObject); private { Private declarations } public { Public declarations } end; var FormMain: TFormMain; implementation uses unitA,unitB; {$R *.dfm} function checkCreatedForm(fm:TForm):boolean; var i : integer; begin Result:=False; for i:=0 to Screen.FormCount-1 do begin if Screen.Forms[i] = fm then begin Result:=True; break; end; end; end; procedure TFormMain.ButnAClick(Sender: TObject); begin FormA:=TFormA.Create(Application); FormA.Show; end; procedure TFormMain.ButnBClick(Sender: TObject); begin FormB:=TFormB.Create(Application); FormB.Show; end; procedure TFormMain.ButnChkClick(Sender: TObject); begin if checkCreatedForm(FormA) = True then ShowMessage('True') else ShowMessage('False'); end; end. unit unitA; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs; type TFormA = class(TForm) procedure FormClose(Sender: TObject; var Action: TCloseAction); private { Private declarations } public { Public declarations } end; var FormA: TFormA; implementation {$R *.dfm} procedure TFormA.FormClose(Sender: TObject; var Action: TCloseAction); begin Action:=caFree; end; end. unit unitB; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs; type TFormB = class(TForm) private { Private declarations } public { Public declarations } end; var FormB: TFormB; implementation {$R *.dfm} end.
←解決時は質問者本人がここをチェックしてください。
戻る
掲示板システム
Copyright 2021 Takeshi Okamoto All Rights Reserved.