Solved

Instance form when needs

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

757 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now