Jump to content


Photo

Autocreate Forms

Autocreate Application Form

  • Please log in to reply
No replies to this topic

#1 EvaF

EvaF
  • Members
  • 9 posts

Posted 02 January 2017 - 11:51 PM

Hello,
I would like to work with multiple forms in my project.
I have looked at "FormsDemo" project, there are two forms, Form1 is created automatically , Form2 is explicitly created and its instance is registered in the procedure TApplication.ApplicationStarting .

The second example "MultipleForms" uses  three Forms, all of them are created and their instances are registered in procedure TApplication.ApplicationStarting explicitly.

I wonder if it is possible to delegate the creation and the registration to the application. It seems to me that this option is already implemented in the SMS, but unfortunatelly due a small bug  the last form is not created at all.

procedure TApplicationFormsList.AutoCreateNextForm;
begin
  for var iForm := FNextAutoCreate to FList.High do begin
    var info := FList[iForm];
    if info.IsAutoCreated and (not assigned(info.Instance)) and (not info.InitialAutoCreateDone) then
    begin
      AutoCreateForm(info);
      Inc(FNextAutoCreate);

//    if FNextAutoCreate < FList.High then      // <--- This test akips the last form 
      if FNextAutoCreate <= FList.High then     // <--- will this fix suffice ?

        w3_SetTimeout(AutoCreateNextForm, 50);
      break; //for iForm
    end;
  end;
end;






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users