From: Harry B. on
Hello!

In an MLE I have some lines of text. How can I calculate the min. width
(in pixel) needed for the MLE for displaying the strings? I can loop
through the MLE strings and count the number of characters, but I need
the width in pixel related to the font.

TIA,
Harry B.
From: Stephen Quinn on
Harry

Take a look at the ReportPro lib/source for conversion routines
- they will show you the API calls required even if you don't use RP.

CYA
Steve


From: Stefan on
Harry,

local hDC as ptr
local si is _winSize
local rc is _winRect

hDC := GetDC(oControl:Handle())

// Variant 1:
for i := 1 upto nLines
...
GetTextExtentPoint32(hDC, String2Psz(cMemoline), SLen(cMemoline),
@si)
nMaxLength := Max(nMaxLength, si.cx)
...
// Variant 2:
DrawText(hDC, String2Psz(cText), SLen(cText), @rc, _or(DT_CALCRECT,
DT_WORDBREAK))

ReleaseDC(oControl:Handle(), hDC)

Stefan
From: richard.townsendrose on
Harry,

in bbrowser there is a function called bfntSizeText() which is very
easy to use. you could do this in a loop as well ...

richard
From: Harry B. on
Stefan,

'Variant 1' was exactly what I searched for!

Thanks a lot,
Harry B.
 |  Next  |  Last
Pages: 1 2
Prev: Printing BARCODEs
Next: rounded borders