<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                [本例 delphi 7 源碼下載](https://www.jianguoyun.com/p/DU2LG1kQxMf4BRjK2VM) 本例定義三個TForm類, TForm1 , TForm2 , TForm3 ,其中:TForm1 為主窗口,對本工程做如下設置: ![](https://box.kancloud.cn/b21ee726b519651cab2c43ae08d35c04_424x402.png) 要把另兩個窗口,從 Auto-Create Forms 移動到 Available forms 中去。打開本界面的方法,菜單 Project-->Options.. 另一種方法,亦可達到相同目的。菜單 Project -->View source 得到如下代碼。 ~~~ program TestPassParam; uses Forms, Unit1 in 'Unit1.pas' {Form1}, Unit2 in 'Unit2.pas' {Form2}, Unit3 in 'Unit3.pas' {Form3}; {$R *.res} begin Application.Initialize; Application.CreateForm(TForm1, Form1); Application.Run; end. ~~~ 此處代碼顯示,只創建了 TForm1 。稍加分析這幾句代碼,就可以靈活運用它們做更多的事情。 傳值方法一:兩個窗口傳值,實質上是類之間傳值,用類的事件,很容易達到這一目的。于是,我們設計 TForm2 類如下: ~~~ unit Unit2; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,Dialogs, StdCtrls; type TForm2 = class; // 提前申明 TOnGetParam = procedure(Sender: TForm2) of object; // 定義一個事件 TForm2 = class(TForm) Edit1: TEdit; Button1: TButton; procedure Button1Click(Sender: TObject); private public OnGetParam: TOnGetParam; // 定義一個事件變量 end; implementation {$R *.dfm} procedure TForm2.Button1Click(Sender: TObject); begin if Assigned(OnGetParam) then OnGetParam(self); //引發事件 Self.Close; end; end. ~~~ 傳值方法二:利用模態窗口的阻塞功能。 以下是 TForm1 中的全部代碼 ~~~ unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, Unit2, Unit3, StdCtrls; type TForm1 = class(TForm) Edit1: TEdit; Button1: TButton; Edit2: TEdit; Button2: TButton; Label1: TLabel; Label2: TLabel; procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); procedure FormDestroy(Sender: TObject); procedure FormCreate(Sender: TObject); private { Private declarations } FForm2: TForm2; procedure GetParamEvent(Sender: TForm2); public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.Button1Click(Sender: TObject); begin // 用事件傳遞,應該重點掌握。 FForm2.Show; end; procedure TForm1.Button2Click(Sender: TObject); var LForm3: TForm3; begin // 用模態窗口傳值,簡單粗暴直觀 // 符合常規思維 LForm3 := TForm3.Create(nil); if LForm3.ShowModal = mrok then // 此句會阻塞(模態窗口的特性) begin Edit2.Text := LForm3.Edit1.Text; end; LForm3.Free; end; procedure TForm1.FormDestroy(Sender: TObject); begin FForm2.Free; end; procedure TForm1.FormCreate(Sender: TObject); begin FForm2 := TForm2.Create(nil); FForm2.OnGetParam := self.GetParamEvent; // 給事件賦值 end; procedure TForm1.GetParamEvent(Sender: TForm2); begin Edit1.Text := Sender.Edit1.Text; end; end. ~~~ 此文介紹的知識點: 1.使 Form 不再自動創建,此方法對 TDataMoudule 同樣有效。 2.事件的初步寫法 3.模態窗口的寫法 面向對象的知識,不復雜,但也不簡單,需要反復練習,才能真正理解。
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看