線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:1609
推到 Plurk!
推到 Facebook!

兩個form 參數傳遞的問題

答題得分者是:hagar
seedbcc
高階會員


發表:232
回覆:272
積分:105
註冊:2003-12-10

發送簡訊給我
#1 引用回覆 回覆 發表時間:2004-12-24 09:43:23 IP:221.169.xxx.xxx 未訂閱
第一個form上面有個 按鈕 按完後,呼叫第二個form 第一個form沒有close 等到第二個form 按 其某個按鈕後, 傳一個值 第二個form close,讓 第一個form 接收 請問我第一個form 要如何 在第二個form按鈕 click 傳參數後 立即接收 並做某判斷 做一些動作
hagar
版主


發表:143
回覆:4056
積分:4445
註冊:2002-04-14

發送簡訊給我
#2 引用回覆 回覆 發表時間:2004-12-24 09:53:52 IP:202.39.xxx.xxx 未訂閱
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

發送簡訊給我
#3 引用回覆 回覆 發表時間:2005-02-18 10:02:07 IP:221.169.xxx.xxx 未訂閱
若我要在form2放二個Tedit 讓使用者輸入數值 若第一個edit 大於 第二個edit所輸入的數值 則讓使用重新輸入 不離開form2 要加入什麼語法??
yorkland
高階會員


發表:2
回覆:138
積分:108
註冊:2004-12-17

發送簡訊給我
#4 引用回覆 回覆 發表時間:2005-02-18 11:43:46 IP:220.130.xxx.xxx 未訂閱
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.
系統時間:2024-06-28 13:26:02
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!