Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

All forms in an application 1

Status
Not open for further replies.

hilbrink

Programmer
Dec 8, 2000
38
0
0
NL
Hi,

I would like to get a list of all forms in my application. What is the best way to retrieve this list?

I know that with application.components I get the components owned by the application, but i have some forms not owned by the application. These forms should be on my list too.

Thanks in advance,

Hilbrink.


 
Open on the menu bar:

Project --> Options and click on the Forms tab

Regards S. van Els
SAvanEls@cq-link.sr
 
I'm sorry, but what i meant was creating this list run-time. So how can i program it in Delphi?
 
There is no way to do that except writing the code yourself. Try using on create event of the forms and store the name of the form in a string array when it is created. And clear the name when on destroy event is called. This is not an easy way but it works at all.
 
If you want to know about displayed(!) forms screen.forms works. But I still couldn't find another way to get the list of all(!) forms.

Thank You...
 
Bedrettin,

If you're looking for the forms in your project, why not load/parse the DPR/DPG file? After all, they're just text files.

However, if you're looking at all forms in your project that are currently instanced, you have a bit of a problem. You said that the application doesn't own all of them. Fine. But, how do you propose to tell the compiler the difference between an unowned form that you instanced and one that was instanced by another application, such as Word, or whatever? Determine the rule and you can code it.

This is why it's important to always specify a valid parent for a window...namely, just in case you need to find a child window at runtime.

FWIW, you can use the enumWindows() to enumerate the active parent windows and enumChildWindows() to enumerate the child windows owned by each parent. These are API functions requiring callbacks. There are several demos available; I believe one is even provided with Delphi itself. It's not easy, but but it has been documented.

Start by searching Borland's TI's and KnowledgeBase. Failing that, I know that some relevant materials can be found on MS's KnowledgeBase.

-- Lance
 
Footpad,

I don't have problems with forms.I have solved the problem as I explained in my 1st answer.

Your message is for Hilbrink, I think. Thank you for your help at all. I'm sure parsing DPR/DPG files will work.

Bedrettin.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top