Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Adjusting FontSize in Memo

Posted on 1998-01-30
5
Medium Priority
?
440 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 200 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

886 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