Prev: Printing BARCODEs
Next: rounded borders
From: Harry B. on 13 Sep 2009 14:57 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 13 Sep 2009 17:25 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 14 Sep 2009 03:48 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 14 Sep 2009 05:35 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 14 Sep 2009 10:15
Stefan, 'Variant 1' was exactly what I searched for! Thanks a lot, Harry B. |