CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: textbox

  1. #1
    Join Date
    Sep 2001
    Posts
    2

    textbox

    I would like to know a text width 1000pcx = how many character?

    thank you


  2. #2
    Join Date
    Jan 2000
    Location
    Olen, Belgium
    Posts
    2,477

    Re: textbox

    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
    Tom Cannaerts
    email: [email protected]
    www.tom.be (dutch site)

  3. #3
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Re: textbox

    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
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

  4. #4
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Re: textbox

    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
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured