Presentation is loading. Please wait.

Presentation is loading. Please wait.

マルチフォーム BCB では親 Form から子 Form を呼び出す ことが出来る。 Unit1.cpp に子 From のヘッダー Unit2.h を インクルードしておく 親 Form から子 Form のメソッド –Show() –ShowModal() を使うことで呼び出せる。

Similar presentations


Presentation on theme: "マルチフォーム BCB では親 Form から子 Form を呼び出す ことが出来る。 Unit1.cpp に子 From のヘッダー Unit2.h を インクルードしておく 親 Form から子 Form のメソッド –Show() –ShowModal() を使うことで呼び出せる。"— Presentation transcript:

1 マルチフォーム BCB では親 Form から子 Form を呼び出す ことが出来る。 Unit1.cpp に子 From のヘッダー Unit2.h を インクルードしておく 親 Form から子 Form のメソッド –Show() –ShowModal() を使うことで呼び出せる。

2 マルチフォーム Show() 子 Form は親 Form と独立して動作する。 OK ボタンや Cancel ボタンを押したとき の 動作はプログラムで記述する

3 マルチフォーム ShowModal() 子 Form が動作中は、親 Form は停止している。 OK ボタンや Cancel ボタンは、そのプロパ ティ ModalResult の値を mrOk や mrCancel に設定 しておくと、戻り値としてこれらの値を返し、 子 Form を閉じる。

4 マルチフォーム void __fastcall TForm1::Button1Click(TObject *Sender) { Form2->ShowModal(); } void __fastcall TForm1::Button2Click(TObject *Sender) { Form2->Show(); }

5 マルチフォーム Form 間のデータのやり取り Form の public プロパティを使うことで やり取りできる

6 マルチフォーム 例: Form2 に public の AnsiString Data を持たせる。 class TForm2 : public TForm { __published:// IDE 管理のコンポーネント TButton *Button1; TButton *Button2; TEdit *Edit1; void __fastcall Button1Click(TObject *Sender); private:// ユーザー宣言 public:// ユーザー宣言 __fastcall TForm2(TComponent* Owner); AnsiString Data; };

7 マルチフォーム Form2 で、 Data にデータを持たせる。 void __fastcall TForm2::Button1Click(TObject *Sender) { Data = Edit1->Text; }

8 マルチフォーム Form1 で、 Form2 の Sho w Modal が mrOk のとき、 Form2 の Data を読み取る。 void __fastcall TForm1::Button2Click(TObject *Sender) { if (Form2->ShowModal() == mrOk) Edit1->Text = Form2->Data; }


Download ppt "マルチフォーム BCB では親 Form から子 Form を呼び出す ことが出来る。 Unit1.cpp に子 From のヘッダー Unit2.h を インクルードしておく 親 Form から子 Form のメソッド –Show() –ShowModal() を使うことで呼び出せる。"

Similar presentations


Ads by Google