Solved

Adjusting FontSize in Memo

Posted on 1998-01-30
5
422 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

839 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