I.T. Discussion Community!
-Collapse +Expand
Delphi
Search Delphi Group:

Advanced
-Collapse +Expand Delphi To/From
To/FromCODEGuides
-Collapse +Expand Delphi Store
PRESTWOODSTORE

Prestwood eMagazine

November Edition
Subscribe now! It's Free!
Enter your email:

   ► MB LobbyPascal and Delphi Coding BoardDelphi Object PASCAL Topic   Print This     

TForm and TComponent

TForm and TComponent in Delphi Object PASCAL topic (part of our Pascal and Delphi Coding group).

Quick Search: TComponent   TForm TComponent  
Matt
Canada
Hi,
I'm trying to find a form by browsing through Delphi's application components and show the form when the right name has been found. Unfortunately, I hit a compiler error I don't know how to go about it.

var
ShowThisForm: TForm ;

begin
for i := 0 to ComponentCount - 1 do
begin
if Application.Components is TForm then
begin
if FrmNam = Application.Components.Name then
begin
ShowThisForm := Application.Components ;
ShowThisForm.Show ;
exit ;
end ;
end ;
end ;
end ;

end ;
 Posted 16 years ago (Thread Starter)
Comment Quote
About Matt -Collapse +Expand
Visit Profile
Approved member.
Member subscribes to this thread with a verified email.

Post ID #10289, 2 replies
Thread Started 1/27/2004 4:45:00 PM
View Counter=3495
Last Reply Posted 1/29/2004 1:50:00 PM)
Location=Canada  
Joined=19 years ago   MB Posts=14  
William Pantoja
Woodinville, WA, USA
This will search through the components held by the Application object. Note--if the form is not yet created, it will not be in the list.

procedure ShowForm (Name : string);

var
I : Integer;
AForm : TForm;

begin
for I := 0 to Application.ComponentCount-1 do
begin
if Application.Components[I] is TForm then
begin
AForm := Application.Components[I] as TForm;
if CompareText(AForm.Name,Name) = 0 then
begin
AForm.Show;
end;
end;
end;
end;


If you are wanting to dynamically create and show forms based on their name--that's a different technique.

---
William Pantoja

Consultant/Software Engineer
ForceOne Technologies, Inc.

 Posted 16 years ago
Comment Quote
About William Pantoja -Collapse +Expand
Visit Profile
Approved member.
Member subscribes to this thread with a verified email.

Post ID #10290 (Level 1.1)  Reply to 10289
Thread Started 1/27/2004 6:36:00 PM
View Counter=2
Location=Woodinville, WA, USA  
Joined=19 years ago   MB Posts=163   KB Posts=1  
Most Recent Post
Matt
Canada
Exactly what I needed to know. Thanks a lot!!
 Posted 16 years ago (Thread Starter)
Comment Quote
About Matt -Collapse +Expand
Visit Profile
Approved member.
Member subscribes to this thread with a verified email.

Post ID #10298 (Level 1.2)  Reply to 10289
Reply Posted 1/29/2004 1:50:00 PM
Location=Canada  
Joined=19 years ago   MB Posts=14  

Revive Thread!

Add a comment to revive this old thread and make this archived thread more useful.

Write a Comment...
Full Editor
...
Sign in...

If you are a member, Sign In. Or, you can Create a Free account now.


Anonymous Post (text-only, no HTML):

Enter your name and security key.

Your Name:
Security key = P1287A1
Enter key:
Icon: A Post    Thread    Idea    Important!    Cool    Sad    No    Yes    Includes a Link...   
Thread #10289 Counter
3495
Since 4/2/2008

Follow PrestwoodBoards on: 


©1995-2020 PrestwoodBoards  [Security & Privacy]
Professional IT Services: Coding | Websites | Computer Tech