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
Solved

Instance form when needs

Posted on 2001-07-22
1
127 Views
Last Modified: 2010-04-06
I had write a big application which having two hundreds  form. It's not a good idea that instance them when application run. So,I save their name in a ListBox, but how to instance a form when it's name in listbox clicked?
0
Comment
Question by:firstshine
1 Comment
 
LVL 17

Accepted Solution

by:
inthe earned 66 total points
ID: 6306447
hi,
you will need to add the units to your uses section and call registerclass with the form class names .
below is rough example ,you may want to save the s and check if its already exists or not..

{note the listbox contains:
TForm2
TForm3
TForm4
        }

implementation

{$R *.DFM}
uses unit2,unit3,unit4;

procedure TForm1.ListBox1Click(Sender: TObject);
var
i : integer;
s : string;
f : TForm;
c : TPersistentClass;
begin
registerClasses([TForm2,TForm3,TForm4]);
i := listbox1.ItemIndex;
s := listbox1.Items.Strings[i];
c := GetClass(s);
if c <> nil then begin
//here you may want to use a stringlist etc to
//check if s is being used currently
//
f := TComponentClass(c).Create(self) as TForm;
f.Show;
end;
end;
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

792 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