Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to set the properties of a component at runtime Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
30-Aug-02
Category
OO-related
Language
Delphi 2.x
Views
46
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Tomas Rutkauskas

I want to set the font property of all my forms, buttons, labels, etc. on 50 
different forms. How do I go about doing this? Is there some RTTI procedure or just 
using the "as" operator? I need this procedure to be recursive, too.

Answer:

You can use RTTI to do this. Here is how to change a particular component:

1   procedure TForm1.BtnClick(Sender: TObject);
2   var
3     p: PPropInfo;
4     f: TFont;
5   begin
6     f := TFont.Create;
7     {Setup the font properties}
8     f.Name := 'Arial';
9     p := GetPropInfo(Sender.ClassInfo, 'Font');
10    if Assigned(p) then
11      SetOrdProp(Sender, p, Integer(f));
12    f.Free;
13  end;


To get at all the forms loop through the Screen global variable. For each form loop through its Components list calling the above procedure (or something close). If you only create your components at design time that is it. If you create some at runtime and the owner is not the form, then for each component loop through its Components list recursively to get at all the owned components.

			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC