Jump to content

Recommended Posts

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;

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×