Go back to Richel Bilderbeek's homepage.
Go back to Richel Bilderbeek's C++ page.
VCL data type for a form, the Component you put all others on. Without any others on it, it is an empty window. Can be found in the header file Forms.hpp.
For code snippets using TForm, go to the VCL graphics code snippets page
There are multiple options when you want to develop an application with multiple forms. You can use Auto-created Forms (default) or create them dynamically yourself. Also you can choose between using normal Forms or use MDI Parents and MDI Childs. MDI is an abbreviation for 'Multiple Document Interface'.
To have multiple (non-parent) TForms in your program, do (using default names):
Now you can type, e.g. under an OnClick event:
Form2->Show(); |
Now you can type, e.g. under an OnClick event:
FormChild->Show(); |
Note that this is not the standard use of an MDI application, as we only have one single Child, which only has one instance. But the Child does have different behaviour compared to standard Forms.
Creating an instance of a Child can be done like this:
//Somewhere in code of FormParent, e.g. under an OnClick Event |
Or using a std::auto_ptr:
//Headers |
But this simple code is not enough, as you probably want to keep the Child Forms on the Parent Form. So you could use a std::vector storing these child pointers. I use the boost::shared_ptr for this:
//UnitFormParent.h |
Then add to FormParent's definitions:
//A button for creating a new Child |
You can get a TForm in a TForm as if it were a TPanel. Go to the page 'Get a TForm in a TForm'.
Making a Form transparent is easy. First set the AlphaBlend property to true. Then the AlphaBlendValue determines the transparency. An AlphaBlendValue of 0 denotes total transparence (you won't see it anymore), an AlphaBlendValue of 255 denotes the standard non-transparency.
Never change the TForm constructor to the following:
__fastcall TFormParent::TFormParent(TComponent* Owner, const int i) //Don't do this! |
This will (strangely) result in a stack overflow.
One workaround is to use AnsiString instead of an integer:
__fastcall TFormParent::TFormParent(TComponent* Owner, const AnsiString i) |
Go back to Richel Bilderbeek's C++ page.
Go back to Richel Bilderbeek's homepage.