Solved

Instance form when needs

Posted on 2001-07-22
1
130 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
[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
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

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!

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses
Course of the Month9 days, 7 hours left to enroll

624 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