|
-
June 21st, 2001, 12:39 PM
#1
Finding the length of text with an API function
Is there an API function which will tell how long (in pixels) a certain amount of text is? I’m writing a status bar control and want the user to be able to know how much space is required for their status text. I though I remember using an API function to do this before, but for the life of me can’t find a function which would do this. Can anyone tell me either which function it is or else let me know that in fact I simply not remember correctly? Thanks.
Mike
-
June 21st, 2001, 01:37 PM
#2
Re: Finding the length of text with an API function
public Declare Function GetTextExtentPoint32 Lib "gdi32" Alias "GetTextExtentPoint32A" (byval hdc as Long, byval lpsz as string, byval cbString as Long, lpSize as POINTAPI) as Long
'
public Type POINTAPI
X as Long ' Character Height
Y as Long ' Width of string
End Type
'
public TextSize as POINTAPI
'
GetTextExtentPoint32 ndc, tx, len(tx), TextSize
' ncd is the hdc of the container for the text
' tx is the string to analyze
' textsize structure is returned values (see comments)
John G
-
June 21st, 2001, 02:27 PM
#3
Re: Finding the length of text with an API function
you can use:
me.ScaleMode = vbPixels
a = me.TextHeight(s)
b = me.TextWidth(s)
l=a*b
I haven't checked that but it should work.
You can play with it as you wish.
----------
The @host is everywhere!
----------
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|