Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7447455
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T12:36:29+00:00 2026-05-29T12:36:29+00:00

Is it possible to tell Unit1 Form1 to create another self , Application.CreateForm(TForm1, Form1);

  • 0

Is it possible to tell Unit1 Form1 to create another self ,

Application.CreateForm(TForm1, Form1);

and trough the first form1 to be able to tell the difference between the original form1 components and the second, new form1 components.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T12:36:32+00:00Added an answer on May 29, 2026 at 12:36 pm

    The simple way to do this without going all object oriented and without resorting to a spaghetti bowl of global variables is to have the form that controls another form hold a reference to the form it needs to control. And it doesn’t matter whether it is the same form or another form class. Though in the latter case you will need to add the form’s unit to the interface section’s uses clause.

    TForm1 = class(TForm)
    private
      FFormToControl: TForm2; // Class member so initialized to nil by the compiler.
    end;
    

    Then somewhere in the code, you will need to instantiate the form that you want to control.

    FFormToControl := TForm2.Create(<Owner>);
    FFormToControl.Show;
    

    For you can use Application, Self or nil. It depends on who you want the owner to be and that depends on who you want to control the lifetime of FFormToControl. If it will simply exist until the application is closed Application will do fine. If it should be freed when Form1 is freed, use Self or nil. Self will ensure that the VCL’s ownership system will take care of freeing. Using nil means that you will have to Free it yourself.

    Afterwards you can simply call methods and set properties of the TForm2 class:

    FFormToControl.DoSomethingCool;
    FFormToControl.EditBackgroundColors := clRed;
    

    If the second form can exist and be closed during the lifetime of a TForm1 instance, then you need to check whether the form has been instantiated before using any of its methods and properties:

    if Assigned(FFormToControl) then begin
      FFormToControl.DoSomethingCool;
      FFormToControl.EditBackgroundColors := clRed;
    end;
    

    You should also do that when FFormToControl is instantiated somewhere other than TForm1’s constructor (or OnCreate) and freed before TForm1’s destructor (or OnDestroy) as you can then never be sure whether FFormToControl is instantiated. In this case you are probably better of to use nil as the owner for FFormToControl and you should make sure that TForm1 is notified when FFormToControl is freed. For example by responding to the OnDestroy event and in its handler setting FFormToControl to nil.

    FFormToControl := TForm2.Create(<Owner>);
    FFormToControl.OnDestroy := HandleForm2Destroy;
    FFormToControl.Show;
    
    
    procedure TForm1.HandleForm2Destroy(Sender: TObject);
    begin
      if Sender = FFormToControl then begin
        FFormToControl := nil;
      end;
    end;
    

    Note:
    When you do create and use a form from its own methods, you will have to be careful to avoid an endless loop of creating the next instance.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Please tell me if it is possible to do the following: create an instance
In a web application using struts2 ejb hibernate, is it possible to tell the
Is it possible to tell what application sent an intent, or any kind of
Is it possible to tell if a workbook has been opened from an email
I understand that it is not possible to tell what the user is doing
As the title says on a website is it possible to tell if a
From within a finally block, is it possible to tell an exception has been
Please tell me whether it is possible to use both SimpleUrlHandlerMapping and AnnotationMapping in
Somebody please tell me it is possible to recover Visual Studio source after VS
Could anyone tell me if it is possible to use the flex 4 framework

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.