Solved

Adjusting FontSize in Memo

Posted on 1998-01-30
5
419 Views
Last Modified: 2010-04-04
I have a DBMemoFiled, where i show data in a 80 CH, 25 lines format (always). I want to automaticly change the font size, based on the memoFieldSize, so i always see the total of 80 chars and 25 lines, but in different Fontsizes ...
I tried to find a formula that mathches those, but the relation is non-linear.
But maybe there some easy way ... ???
0
Comment
Question by:jvh042097
5 Comments
 
LVL 2

Expert Comment

by:Waldek
ID: 1357956
You must use a font where a width of char is equal example
Courier New . You may calculate a width of 80 chars and resize width of memo to nearly of width 80 char. With heigth You may do the same
0
 

Author Comment

by:jvh042097
ID: 1357957
That's not the point. I can easely mannually construct a table with different fontsizes for Courier New, and minimal MemoField Widths and Heigths. But than i'm stuck to that particular Font. I tried to construct a mathematical function which describes this relationship, but strange, it's not linear, not even quadratic, but sure third or even fourth power. But still only usable for that particular font. I'm looking for a system function which tells me the excact dimension of one character.
Of course, all this only for fixed spaced characters !!!

0
 
LVL 5

Expert Comment

by:inter
ID: 1357958
Dear jvh,

There is a method called TextWidth of TCanvas. So in run time you can find the width of any string due to the TFont selected for that TCanvas. So by using this function you may do the following:

1 - Create a canvas object at the begining of the program.
2 - Create a font (any font).
3 - When you should display the text in DB to one of your components conduct a simple search by playing with the Size of the font so that TCanvas.TextWidth('you string') is optimally fit in to component. So we should determine font size here.
4 - Once you have found it, select it as the font of the component you want
5 - Do 3,4 when ever text is to be changed
6 - Free the canvas and font upon exit.

I am sure this does not take more than few milliseconds. Please give your comment

Sincerely,
Igor
0
 
LVL 4

Accepted Solution

by:
tomerlei earned 100 total points
ID: 1357959
look in the memo properties
and choose the option "font"
and then choose your font
0
 

Author Comment

by:jvh042097
ID: 1357960
Tomerlei,

do you really understand the problem ??? I suppose you're not really "an expert", don't you !!!!


0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now