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 resize controls according to the users font settings 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
Others
Language
Delphi 2.x
Views
105
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Tomas Rutkauskas

How to resize controls according to the users font settings

Answer:

You don't need the resolution (unless you plan on rearranging the controls on your 
form depending on resolution). You can get the appropriate "base unit" for sizing 
controls like this:

1   
2   BaseUnit := Canvas.TextHeight('0');



This returns a value which is 8 times what Windows calls a "dialog unit." Every 
control can be sized to some integral number of dialog units. For example, I 
normally make my buttons 40 units wide and 14 units tall. So the code would go 
something like this:


3   ButtonWidth := (40 * BaseUnit) div 8;
4   ButtonHeight := (14 * BaseUnit) div 8;
5   MyButton.SetBounds(L, T, ButtonWidth, ButtonHeight);



This will resize the button in accordance with whatever the user's font size setting happens to be. It is the font.height that changes during the automatic scaling of the form (if you leave form.scaled set to true) and this will make the component scale as well.

			
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