Click to See Complete Forum and Search --> : textbox


[G]kk
September 4th, 2001, 09:15 AM
I would like to know a text width 1000pcx = how many character?

thank you

Cakkie
September 4th, 2001, 09:35 AM
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
slisse@planetinternet.be

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

Cimperiali
September 4th, 2001, 11:06 AM
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: KPDTeam@Allapi.net
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

Cimperiali
September 4th, 2001, 11:08 AM
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