Re: How to calculate REAL text extent.cx
From: Michael (NOSPAMmao_at_vnet.net)
Date: 02/27/04
- Next message: John: "Re: Free Beer!!"
- Previous message: CheckAbdoul: "Re: dlls - getting started"
- In reply to: Joseph M. Newcomer: "Re: How to calculate REAL text extent.cx"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 27 Feb 2004 11:42:16 -0500
I have an ocx with a textbox (non-window) so all I get is a rect area. The
OnDraw() controls displaying the text. I'm trying to size the rect area when
the font point size changes. The TEXTMETRIC gives enough information to size
vertical (tmHeight,tmExternalLeading,tmInternalLeading) but the
tmAveCharWidth and tmMaxCharWidth don't seem to be accurate enough to allow
me to modify the size so that the string fits horizontally within the box.
"Joseph M. Newcomer" <newcomer@flounder.com> wrote in message
news:hhht30lmh43n6ebhj057iu631c91amueqi@4ax.com...
> Also, when you say "too short", what are you measuring against? For
example, if you are
> using it to determine the size of a control, remember that you have to
allow for the
> borders of the control and any text offsets inside the control.
> joe
>
> On Fri, 27 Feb 2004 11:08:01 +1100, "Jase"
<jshelley@spamblock.enersol.com.au> wrote:
>
> >"Michael" <NOSPAMmao@vnet.net> wrote in message
> >news:ete6DQM$DHA.2180@TK2MSFTNGP09.phx.gbl...
> >> Anyone know how to calculate the x extent of a string? I've tried
> >> GetTextExtent() and the width is short. GetCharABCWidths() returns the
> >same
> >> width as GetTextExtent(). I'm trying to adjust the rectangle to fit
around
> >> the text dynamically. I'm using TEXTMETRIC to get the y extent which
work
> >> well enough but the tm.tmAveCharWidth is too little and the
> >> tm.tmMaxCharWidth is tooo much. I need something that is juuuuuuuust
> >right.
> >> Thanks
> >>
> >
> >GetTextExtent has always worked for me. Perhaps:
> >1. Your text includes tab chars, in which case you need to use
> >GetTabbedTextExtent(...)
> >2. You haven't selected the font into the dc before calling
> >GetTextExtent(...)
> >
> >Hope that helps.
> >
> >Jase
> >
>
> Joseph M. Newcomer [MVP]
> email: newcomer@flounder.com
> Web: http://www.flounder.com
> MVP Tips: http://www.flounder.com/mvp_tips.htm
- Next message: John: "Re: Free Beer!!"
- Previous message: CheckAbdoul: "Re: dlls - getting started"
- In reply to: Joseph M. Newcomer: "Re: How to calculate REAL text extent.cx"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|