0

I'd like to know how I can check that all the controls on the form are created and initialized.

I have a form I am showing when a user presses the update button. It has only a TProgressBar control.

The handle is not NULL for this control and at random stages it can or can't set the Position/Max values.

When I set TProgressBar->Max value to some integer it remains 0 after.

So the question is:

  1. How to really create the form and all controls on it (i am currently using just Form->Show() method, which as I can check calls the constructor)

    Also I have following form creation code in main cpp file:

    Application->CreateForm(__classid(TupdateProgramForm), &updateProgramForm);

  2. How to check that all controls on the form are created and PAINTED (showed and visible)

Johan
  • 74,508
  • 24
  • 191
  • 319
ergey
  • 51
  • 1
  • 5
  • 1
    The function `Form->Show()` does not call the constructor, your new statement calls the constructor. If you've set the form to be autocreated it will happen in the main function, as far as I recall in the application object. – Tommy Andersen May 30 '10 at 19:54
  • Thanks, Please can u give example? I am just creating the form through application->createform, not using new[] operator. – ergey May 31 '10 at 04:28
  • Tommy's comment still applies. TApplication.CreateForm() fully creates the Form object and its child controls. – Remy Lebeau Jun 02 '10 at 19:10

2 Answers2

0

In C++ Builder the form and the controls created at design-time are translated into binary objects through automatic scripts that produce Delphi code.

To view the originated Delphi code just right-click anywhere on form at design-time and select 'View as text'. This will show the Delphi source code of the form and it's controls.

Guildenstern70
  • 1,715
  • 18
  • 18
0

After a form and all child controls created, the OnCreate event of that form invoked and you can place your initialization and checking code in this event, for example:

void __fastcall TfrmMain::updateProgramFormCreate(TObject *Sender)
{
   ProgressBar->Max = 100;
   ProgressBar->Value = 20;
}
mh taqia
  • 3,506
  • 1
  • 24
  • 35
  • 1
    using OnCreate/OnDestroy are generally frowned on for c++. The constructor/destructor are more reliable. – David Dean May 10 '12 at 15:17
  • 1
    Yes, do not use `OnCreate` and `OnDestroy` in C++. Due to quirks/bugs in the handling of the `OldCreateOrder` property, they can sometimes be triggered before the derived constructor and after the derived destructor, respectively, which is illegal in C++ and can lead to crashes. Use the actual constructor and destructor instead. The DFM has already been fully loaded before the derived constructor runs. Or you can override the form's virtual `Loaded()` method, which gets calls at the end of DFM loading. – Remy Lebeau May 10 '12 at 17:57