Solved

Instance form when needs

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

Industry Leaders: 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

Suggested Solutions

Title # Comments Views Activity
delphi parse string to params 3 151
update joined tables 2 62
Firemonkey Tcameracomponent resultion 1 20
Get weeknumber and year from date 4 25
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…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

679 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