I would like to know a text width 1000pcx = how many character?
thank you
Printable View
I would like to know a text width 1000pcx = how many character?
thank you
In most fonts, you cannot determin how many characters can fit in a specific length. You can only get the width of a text, not the characters that would fit a width.
On the other hand, some fonts (monotype fonts), have a fixed width for every character. In this case, you could determine it.
Tom Cannaerts
[email protected]
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook
maybe
Private Declare Function GetWindowTextLength Lib "user32"
Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long
can help you...
from api-guide:
The GetWindowTextLength function retrieves the length, in characters, of the
specified window’s title bar text (if the window has a title bar). If the
specified window is a control, the function retrieves the length of the text
within the control
private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (byval hwnd as Long, byval lpString as string, byval cch as Long) as Long
private Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (byval hwnd as Long) as Long
private Sub Form_Activate()
'KPD-Team 1999
'URL: http://www.allapi.net/
'E-Mail: [email protected]
Dim MyStr as string
'Create a buffer
MyStr = string(GetWindowTextLength(me.hwnd) + 1, Chr$(0))
'get the window's text
GetWindowText me.hwnd, MyStr, len(MyStr)
MsgBox MyStr
End Sub
Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, TCartwright, Bruno Paris, Dr_Micahel
and all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.
The Rater
Or maybe better:
(api-guide)
The GetTextExtentPoint32 function computes the width and height of the
specified string of text. This function supersedes the GetTextExtentPoint
function
Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, TCartwright, Bruno Paris, Dr_Micahel
and all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.
The Rater