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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Listing Components against a given form name

Status
Not open for further replies.

StevenK

Programmer
Jan 5, 2001
1,294
GB
I want to write a procedure in a 'Global' unit such that I pass the procedure the name of a form (i.e. 'Form1') as a string.
The procedure will then cycle through the list of components that are in that named form and output them into a TStringList.
I can achieve this (with no hassle) if the procedure is coded within the scope of the form in question.
In order to achieve this I first need to see within the scope of the form (from the external 'Global' unit).
Can anyone suggest a method I can use to first get a lock on the form (the form name as passed to the external 'Global' unit) and then run a list of the components that are found in the form.
How can I do this ?
Thanks in advance.
Steve
 
Hi,

in the "global unit" do this

function Compform(currform:TForm):tstringlist;
begin
.........//your code
with currform do
for ix:=0 to ComponentCount-1 do
stringlist.add(TComponent(Components[ix]).Name)

........//your code
........

end;

AND IN EACH OF THE FORM YOU HAVE TO WRITE
AFTER INCLUDING THE GLOBAL UNIT
Compform(self);

***Hope this helps


 
Thanks for the function suggestion.
As luck would have it, and following a couple of hours of trial and error I managed to battle through to a similar resultant function.
I'm actually performing a FindComponent on the component name and then changing properties of the components, namely the Caption, whether or not it is Visible, etc.
Thanks again.
Steve
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top