子視窗關閉重新執行程式 |
答題得分者是:pceyes
|
bluerurutia
一般會員 ![]() ![]() 發表:1 回覆:0 積分:0 註冊:2008-11-28 發送簡訊給我 |
|
pceyes
尊榮會員 ![]() ![]() ![]() ![]() ![]() ![]() 發表:70 回覆:657 積分:1140 註冊:2003-03-13 發送簡訊給我 |
1. 在Form1上拉二個Button
2. File -> New -> Form 兩次 (加入兩個新Form) 3. Project -> Options -> Forms 將Form2及Form3 由Available forms: 4. 檢查你的Unit1, Unit2, Unit3和我的沒有不同,編譯後測測看,是不是你要的。 [code delphi] // 這是你的主程式 unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) Button1: TButton; Button2: TButton; Label1: TLabel; procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} uses Unit2,Unit3; // uses 你的子視窗 // 按鍵開啟你的子視窗 form2 procedure TForm1.Button1Click(Sender: TObject); begin form2 := TForm2.Create(application); // 動態產生你的子視窗 if form2.ShowModal = mrok then begin showmessage('mrok'); end; end; // 按鍵開啟你的子視窗 form3 procedure TForm1.Button2Click(Sender: TObject); begin form3 := TForm3.Create(application); // 動態產生你的子視窗 if form3.ShowModal = mrNo then begin showmessage('mrNo'); end; end; end. [/code] [code delphi] // 子程式1 unit Unit2; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, StdCtrls; type TForm2 = class(TForm) Button1: TButton; Image1: TImage; Label1: TLabel; procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form2: TForm2; implementation {$R *.dfm} procedure TForm2.Button1Click(Sender: TObject); begin modalresult := mrok; end; end. [/code] [code delphi] // 子程式2 unit Unit3; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm3 = class(TForm) Label1: TLabel; Button1: TButton; procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form3: TForm3; implementation {$R *.dfm} procedure TForm3.Button1Click(Sender: TObject); begin modalresult := mrNo; end; end. [/code]
------
努力會更接近成功 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |