Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Runtime creation of my Form

Posted on 2004-04-03
8
Medium Priority
?
393 Views
Last Modified: 2010-04-05
Don't know how many experts use Billenium package - bad boys if not use :), very good library.
Anyway I think that you can help me in any case. Untill now I embedded a form in my container using next code:

     Form2 := TForm2(W1.CreateForm(TForm2));
     W1.ShowForm(Form2, True);

All ok, just that now I create my Form2 on runtime.

with TForm.Create(Self) do Name:='Form2';
Form2 := TForm2(W1.CreateForm(TForm2));
W1.ShowForm(Form2, True);

In this case I get message that Form2 is unknown ( and I know that is true but don't know how to use after runtime creation )

Any help ?
0
Comment
Question by:ginsonic
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 9

Author Comment

by:ginsonic
ID: 10748542
Attention, can't use:

VAR  
FORM1  :  TFORM;  
BEGIN  
  FORM1:=TFORM.CREATE(SELF);  

because sometimes I create 1-2 forms, someelse more than 20, so I can't add var Form2, Form3 ....Form n
0
 
LVL 17

Assisted Solution

by:mokule
mokule earned 1000 total points
ID: 10748572
But for
Form2 := TForm2(W1.CreateForm(TForm2));
You must declare Form2.
You can use this variable for all created forms
0
 
LVL 12

Accepted Solution

by:
esoftbg earned 1000 total points
ID: 10749003
there is  ways:
and

procedure TForm1.Button1Click(Sender: TObject);
begin
//  Form2 := TForm2.Create(nil);
//  Form2 := TForm2.Create(Self);
//  Form2 := TForm2.Create(Application);
  Application.CreateForm(TForm2, Form2);
  try
    Form2.ShowModal;
  finally
    Form2.Release;
    Form2 := nil;
  end;
end;

emil
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 27

Expert Comment

by:kretzschmar
ID: 10749248
what is W1 ?
0
 
LVL 9

Author Comment

by:ginsonic
ID: 10750908
I try to use Application.CreateForm(TForm2, Form2) but the form must be added to project.

I have a script where I get some questions. Depend of the questions number I will create a new form for each 15 questions.
For 48 questions, for example, I will host 4 new forms.

I can't create these forms at design mode because I can't know what type of vcl will use and the number of vcl ( editboxes, comboboxes, own vcl for datetime ... ).

What do the program. The client need to evaluate each case using a quizz ( a questions set ). This set can be changed each month so I wish to make it a little 'visual'. The client make a script that will contain all informations about questions:

Question1.Text
Question1.VCL.Name
Question1.VCL.Type
........
Question1.Record.Name
.....

Using this script I wish to create forms, to populate these with VCL and assign events. A little harder for my experience, but I like the challenge.

For kretzschmar,

W1 is a FormContainer. I create Form2 and embedded into W1 form container.

0
 
LVL 9

Author Comment

by:ginsonic
ID: 10750910
BTW, W1 is created at runtime too, but I have an algorithm to find this component by name. Unfortunatelly can't find a new form by name.

var c: TComponent;
...
C := FindComponentEx('Form1.W1');
0
 
LVL 9

Author Comment

by:ginsonic
ID: 10750915
And then ... TFormContainer(C).Visible := True; or something else.
0
 
LVL 9

Author Comment

by:ginsonic
ID: 10759343
I will use a dynamic form array.
0

Featured Post

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question