Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Instance form when needs

Posted on 2001-07-22
1
Medium Priority
?
133 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 264 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
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 anti-spam), the admin…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

885 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