You use WidthTwips = .Right * (TWIPSPERINCH / lngDPI) to calculate width. Is
GetDeviceCaps returning the wrong value? If so, what problems would I have
if lngDPI is adjusted for this calculation?
"Stephen Lebans" <ForEmailGotoMy.WebSite.-WWWdotlebansdot...@linvalid.com>
wrote in message news:Q13bg.9444$A26.235823@ursa-nb00s0.nbnet.nb.ca...[color=blue]
> The solution is not to change an intrinsic constant. You are now tied to[/color]
the[color=blue]
> current resolution setting of your graphics card.
>
> --
>
> HTH
> Stephen Lebans
>
http://www.lebans.com
> Access Code, Tips and Tricks
> Please respond only to the newsgroups so everyone can benefit.
>
>
> "paii, Ron" <paii@packairinc.com> wrote in message
> news:GaednXNfJ8el6vHZnZ2dnUVZ_sidnZ2d@athenet.net. ..[color=green]
> > Well I found a solution for my application. Increase the TWIPSERINCH
> > constant from
> >
> > Private Const TWIPSPERINCH = 1440
> >
> > To
> >
> > Private Const TWIPSPERINCH = 1600
> >
> > This gave me much finer control than reducing the character count in
> > GetLeftQty().
> > I would like to thank Stephen Lebans for very useful function.
> >
> > "paii, Ron" <paii@packairinc.com> wrote in message
> > news:er-dnVrBy_L17_HZnZ2dnUVZ_vGdnZ2d@athenet.net...[color=darkred]
> >> On further study, fTextWidth() underestimates the TWIPS with my font
> >> settings by 1-2 characters. My subtracting 2 characters just made it[/color][/color][/color]
look[color=blue][color=green][color=darkred]
> >> like an overestimate.
> >>
> >> Font Name: MS Sans Serif
> >> Font Size: 8
> >> Font Weight: Normal
> >> Font Italic: No
> >> Font Underline: No
> >> Text Align: General
> >>
> >> Width: 1.7854"
> >> Height: 1.1458"
> >>
> >> I tried the following change, which gave me the same results as the[/color]
> > supplied[color=darkred]
> >> code.
> >>
> >> lngRet = apiDrawText(hDC, sText, -1, sRect, DT_CALCRECT Or DT_BOTTOM Or
> >> DT_LEFT Or DT_EXTERNALLEADING Or DT_NOCLIP Or DT_SINGLELINE)
> >>
> >> "paii, Ron" <paii@packairinc.com> wrote in message
> >> news:vaqdnU1LucG07PbZnZ2dnUVZ_tednZ2d@athenet.net. ..
> >> >
> >> > "Randy Harris" <please@send.no.spam> wrote in message
> >> > news:lgGag.28449$4L1.19766@newssvr11.news.prodigy. com...
> >> > > * Tom van Stiphout:
> >> > > > On Wed, 17 May 2006 07:37:52 -0500, "paii, Ron"[/color]
> > <paii@packairinc.com>[color=darkred]
> >> > > > wrote:
> >> > > >
> >> > > > There is no easy way to do this. The Windows API GetTextExtent[/color][/color][/color]
and[color=blue][color=green]
> > its[color=darkred]
> >> > > > cousins will give you some information, but this is not a trivial
> >> > > > route to take.
> >> > > >
> >> > > > -Tom.
> >> > > >
> >> > > >
> >> > > >> Sorry about that last one.
> >> > > >>
> >> > > >> Does anyone know how to calculate the width a string of text for
> >> given
> >> > Font
> >> > > >> name and size?
> >> > > >> I want to buildup a block of text strings to display in a[/color][/color][/color]
unbound[color=blue][color=green][color=darkred]
> >> > control,
> >> > > >> that has limited width but multiple lines. Currently I am using
> >> > > >> the
> >> > left$()
> >> > > >> function to trim the text to a standard number of characters. I[/color]
> > want[color=darkred]
> >> a
> >> > > >> function to return the number of characters that will fit in the
> >> width
> >> > of
> >> > > >> the control. To keep the output nice, I don't want to use a[/color][/color][/color]
fixed[color=blue][color=green][color=darkred]
> >> pitch
> >> > > >> font.
> >> > > >>
> >> > > >
> >> > >
> >> > > I didn't have the time to go check it out, but I think Stephen[/color][/color][/color]
Lebans[color=blue][color=green][color=darkred]
> >> > > has a solution for this.
> >> > >
> >> > > --
> >> > > Randy Harris
> >> > > tech at promail dot com
> >> > > I'm pretty sure I know everything that I can remember.
> >> >
> >> > I tried Stephen Lebans TextHeightWidthVer45.mdb database with the[/color]
> > function[color=darkred]
> >> > GetLeftQty() to calculate the number of characters that will fit into[/color]
> > the[color=darkred]
> >> > control.
> >> > fTextWidth() sometimes underestimates the TWIPS causing my character[/color]
> > count[color=darkred]
> >> > to be high. and other times overestimates the TWIPS causing my
> >> > character
> >> > count to be low.
> >> >
> >> > Public Function GetLeftQty(ctlr As Control, strTxt As String, lmax As
> >> > Integer) As Integer
> >> > ' Function returns the number of character of strTxt that will fit[/color][/color][/color]
in[color=blue][color=green][color=darkred]
> >> > 1
> >> > line of control ctlr
> >> >
> >> > Dim iLen As Integer ' Text length
> >> > Dim lngTextWidth As Long
> >> > Dim ctlW As Long
> >> >
> >> > ctlW = ctlr.Width
> >> > iLen = Len(strTxt)
> >> > If lmax > 0 Then
> >> > iLen = MinV(iLen, lmax)
> >> > End If
> >> >
> >> > Do While iLen > 1
> >> > lngTextWidth = fTextWidth(ctlr, Left$(strTxt, iLen))
> >> >
> >> > ' Does text fit? If yes then exit
> >> > If lngTextWidth < ctlW Then Exit Do
> >> >
> >> > ' Decrease text length
> >> > iLen = iLen - 1
> >> > Loop
> >> > If iLen > 2 Then
> >> > iLen = iLen - 2
> >> > End If
> >> > GetLeftQty = iLen
> >> > 'Debug.Print iLen & ", " & fTextWidth(ctlr, Left$(strTxt, iLen))[/color][/color][/color]
&[color=blue][color=green]
> > ",[color=darkred]
> >> "
> >> > & ctlr.Width & ", " & Left$(strTxt, iLen)
> >> > End Function
> >> >
> >> >
> >>
> >>[/color]
> >
> >[/color]
>
>[/color]