Solved

Adjusting FontSize in Memo

Posted on 1998-01-30
5
425 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

734 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