Solved

Get Form Name as  variable and Open the Form

Posted on 2000-03-05
9
258 Views
Last Modified: 2010-04-04
I'm using a ListView component with multiple items in it. The contents of the ListView depends on what item is selected in a TreeView. (So the ListView can change dynamically.) I want to link every item in the listview to a form name, and then depending on what item gets double clicked, the associated form must open. Is it possible to do this without If..Then or Case etc. statements, as I'm talking about a lot of forms here! I was hoping to use a variable or something that gets the form name from the SubItem of the Treeview and then create the form. Please Help Urgently!!
0
Comment
Question by:jannie030200
[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
9 Comments
 
LVL 6

Expert Comment

by:edey
ID: 2586084
Name is the name of the control as referenced in the application’s code.

TComponentName: string;
property Name: TComponentName;



GL
Mike
0
 

Expert Comment

by:zb_russia
ID: 2586400
Sample:

  case ListView.Selected.Index of
    0: begin
      dlgGetCodeCard := TdlgGetCodeCard.Create( Self );
      try
        if ShowModal = mrOk ...
      finally
        dlgGetCodeCard.Free;
      end;
    end;
    1: begin
      ...
    end;
  end;


0
 

Author Comment

by:jannie030200
ID: 2587060
Thanks Zb, but the reason why I don't want to use case statements for this (as I mentioned in my original question) is that the index of the selected Item may vary depending on what user is logged on to the program. So it is impossible to link say ViewList.Selected.Index (say selected index = 0) to a fixed frmName, because when the next user logs on that very same item might have an index of say 10. I hope this clarifies the problem a bit. If it is possible to do something with the case statement and I'm just being stupid, can you please give me a bit more of the code I need to do this.

I think that maybe Edey's comment is a step in the right direction, but I'm quite new to the Delphi Environment and haven't got the foggiest as to how to declare properties..

Thx
Jannie
0
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!

 
LVL 27

Expert Comment

by:kretzschmar
ID: 2587084
hi jannie,

each node has a data-property (type pointer). here you can append all you need also objects(forms) or typed records.

meikl
0
 

Author Comment

by:jannie030200
ID: 2587118
Thanks Zb, but the reason why I don't want to use case statements for this (as I mentioned in my original question) is that the index of the selected Item may vary depending on what user is logged on to the program. So it is impossible to link say ViewList.Selected.Index (say selected index = 0) to a fixed frmName, because when the next user logs on that very same item might have an index of say 10. I hope this clarifies the problem a bit. If it is possible to do something with the case statement and I'm just being stupid, can you please give me a bit more of the code I need to do this.

I think that maybe Edey's comment is a step in the right direction, but I'm quite new to the Delphi Environment and haven't got the foggiest as to how to declare properties..

Thx
Jannie
0
 

Author Comment

by:jannie030200
ID: 2587146
hi meikl

I feel like an idiot at this point in time but I'm really lost here!

I see that the data property thing will work. If I got a table that looks something like this:
ID  Descr     FormName
1   Options   frmOptions
2   Setup     frmSetup  etc etc

If the Item in the ListView has got the caption of the descr for eg. 'Options' , I can obviously lookup the record in the table and then see that 'frmOptions' is associated with the ListView Item. The FormName is stored as Text. How can I Read that FormName into the Data Property of the Item and use that Data property to open a form when I double click the Item.

If you can, please include some code to help me understand this.
Cheers.
0
 

Accepted Solution

by:
zb_russia earned 50 total points
ID: 2587246
I are sorry for bad English, I not absolutely correctly have understood your question (small colloquial practice).

As it seems, there is a most simple mode to load the form, on her name (not the variant is considered, when there is a loading of a stream, the names of classes and so on) are formed dynamically. It - all the same problem case/of.

How it is possible to receive a name of a charged window? If this window is present as a name of the element in ListView (then we simple use ListView.Selected.Name) and then through if Name = " we discover the outcome, necessary to us.

If we use a not obviously circumscribed name (as in your example), then the intermediate array (or table) is used, that again a problem to reduce to a call of the chosen window.

For a case with a loading from a stream (the storage of the form in a data base) me needs to be re-read Rey Konopka, I now fast can not recollect singularities of a realization of a loading and unloading of the form in a stream.
0
 
LVL 3

Expert Comment

by:julianpointer
ID: 2589493
When are you creating each form ...

do you have some code like this to create each instance of a form

Form:=TForm.Create(self)
Form.Show;


or do you load each form when the  application is created.

0
 

Author Comment

by:jannie030200
ID: 2591997
Hi Julian,

the forms should bw created at runtime and by looking at your statement,
Form:=TForm.Create(Self)
Form.Show;

I need Form to be anything depending on what Item in the listview gets double clicked for eg.

frmMain := TfrmMain.Create(Self) and then the next time i click on the Icon it might need to execute something lik

frmNew := TfrmNew.Create(self);
0

Featured Post

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

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…
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…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
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…

691 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