Solved

Adjusting FontSize in Memo

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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
TVirtualStringTree  search using TEdit 7 121
Path  to current project in Delphi. 2 79
Convert GUI app into console app for Win32 Env 5 100
Delphi...Split view - idea? 1 68
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 Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

773 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