兩個form 參數傳遞的問題 |
答題得分者是:hagar
|
seedbcc
高階會員 ![]() ![]() ![]() ![]() 發表:232 回覆:272 積分:105 註冊:2003-12-10 發送簡訊給我 |
|
hagar
版主 ![]() ![]() ![]() ![]() ![]() ![]() 發表:143 回覆:4056 積分:4445 註冊:2002-04-14 發送簡訊給我 |
Form1:
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 declarations } public { Public declarations } end; var Form1: TForm1; implementation uses Unit2; {$R *.DFM} procedure TForm1.Button1Click(Sender: TObject); var TmpValue: integer; begin Form2.ShowModal; // 顯示 Form2(這裡 Form2 是 Auto-Create) if Form2.ModalResult = mrOK then // 確定 Form2 是經由 Form2.Button1 關閉的 begin TmpValue := Form2.MyValue; // 取得 Form2 的 FMyValue 變數值 ShowMessage(IntToStr(TmpValue)); end; end; end.Form2: unit Unit2; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Buttons; type TForm2 = class(TForm) BitBtn1: TBitBtn; // BitBtn1 的 ModalResult 屬性設為 mrOK procedure BitBtn1Click(Sender: TObject); private FMyValue: integer;[/red public [red]property MyValue: integer read FMyValue; end; var Form2: TForm2; implementation {$R *.DFM} procedure TForm2.BitBtn1Click(Sender: TObject); begin FMyValue := 12; end; end-- 棒球是從兩出局開始的. 發表人 - hagar 於 2004/12/24 09:59:59 |
seedbcc
高階會員 ![]() ![]() ![]() ![]() 發表:232 回覆:272 積分:105 註冊:2003-12-10 發送簡訊給我 |
|
yorkland
高階會員 ![]() ![]() ![]() ![]() 發表:2 回覆:138 積分:108 註冊:2004-12-17 發送簡訊給我 |
ModuleResult有許多種回應可以選擇, 有些並不會做跳離的動作。
你可以選擇mrNone, 然後提出Error Message, 然後再將Focus重新指回第一個TEdit. mrNone 0 None. Used as a default value before the user exits.
mrOk idOK The user exited with OK button.
mrCancel idCancel The user exited with the CANCEL button.
mrAbort idAbort The user exited with the ABORT button.
mrRetry idRetry The user exited with the RETRY button.
mrIgnore idIgnore The user exited with the IGNORE button.
mrYes idYes The user exited with the YES button.
mrNo idNo The user exited with the NO button.
mrAll mrNo 1 The user exited with the ALL button. mrNoToAll mrAll 1 The user exited with the NO TO ALL button.
mrYesToAll mrNoToAll 1 The user exited with the YES TO ALL button.
|
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |