[Home]  [Edit this page]  [Recent Changes]  [Special Pages]  [Help
CppBuilderCreateAnotherForm

(C++ Builder) Add another Form to your main Form in

There are five options:
  • 1) Single document interface, static other Form
  • 2) Single document interface, dynamically allocated other Form
  • 3) Multiple document interface, static other Form
  • 4) Multiple document interface, dynamically allocated other Form
  • 5) Add a Form in another Form, like a  ?TPanel
Option #1 applies to SDI's in which the other Form does not take parameters supplied by the second (e.g. an About Box). Option #2 applies to SDI's in which the other Form does not take parameters supplied by the second (e.g. the main game screen appearing after the 'Choose your fighter' screen, then the main game screen needs to know which fighters the user chose). Options #3 and #4 are the same, except for MDI's.

Single document interface, static other form

Do, when your Main Form is open only: 'Project | Add to Projects | UnitOtherForm.cpp' 'File | Include Unit Hdr' and select 'UnitOtherForm.cpp' To make the other From visible, type:
OtherFrom->Show();


Single document interface, dynamically allocated other form

This example is for a fighting game, in which the user is in the 'Choose your fighter' screen, and is done. Then, a 'Loading game' screen appears, until the main game screen appears (which needs time to initialize the game).

Do, when the ChooseYourFighter Form is in focus:
  • 'File | Include Unit Hdr' and select 'UnitLoadingScreen.cpp'
  • 'File | Include Unit Hdr' and select 'UnitGameMain.cpp'
  1. include <memory>
void __fastcall TFormChooseFighter::OnButtonDoneClick(TObject * Sender) { this->Hide(); const std::auto_ptr<TFormLoadingScreen> formLoadingScreen(new TFormLoadingScreen(this)); formLoadingScreen->Show(); const std::auto_ptr<TFormGameMain> formGameMain(new TFormGameMain(this)); formLoadingScreen->Hide(); formGameMain->ShowModal(); this->Show(); }


Multiple document interface, static other Form

Later, nearly same like SDI.

Multiple document interface, dynamically allocated other Form

Later, nearly same like SDI.

Add a Form in another Form, like a  ?TPanel

As TForm inherits from TWinControl, see adding VCL TWinControl dynamically or  ?adding CLX TWinControl dynamically. Do not forget to set the TForm's BorderStyle to bnNone.

Topic links



last edited (June 13, 2007) by bilderbikkel, Number of views: 3632, Current Rev: 9 (Diff)

[Edit this page]  [Page history]  [What links here]  [Discuss this topic]  [Printer Friendly]  

Members

Username:

Password:


Register
Forgot Password?




Programmers Heaven - for .NET, Java, C/C++ and WEB Developers!
© 1996-2008 Community Networks Ltd. All rights reserved. Reproduction in whole or in part, in any form or medium without express written permission is prohibited. Violators of this policy may be subject to legal action. Please read Terms Of Use and Privacy Statement for more information. Development by Tore Nestenius at .NET Consultant - Synchron Data.