Results 1 to 9 of 9

Thread: vbCr and EM_GETLINE

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Dec 2005
    Posts
    230

    vbCr and EM_GETLINE

    Hi guys,

    I really need help. This is what i try to do:

    Code:
    For i = 0 To lngCount
    lngLength = SendMessage(hwnd, EM_LINELENGTH, i, 0)
    strBuffer = Space$(lngLength)
    Call SendMessageStr(hwnd, EM_GETLINE, i, ByVal strBuffer)
    strRichText = strRichText & strBuffer
    Next
    MsgBox (strRichText)
    The problem is :
    the strRichtext don't concatenate the 2 or 3 lines together.
    + For some reason lngLength return max 109 event that the line is longer than that.

  2. #2

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Dec 2005
    Posts
    230

    Re: vbCr and EM_GETLINE

    Sorry i don't get what do you mean source ? It's a richedit20a.

  4. #4
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: vbCr and EM_GETLINE

    Source means "where do you read your text from?"

    What exactly are you trying to accomplish?
    If you need to assign text from RichTextBox control then why are you looping?
    Why are you using api at all?Do you need to get selected text only?



    You need to explain and give us as much details as you can possibly do. Thanks.

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Dec 2005
    Posts
    230

    Re: vbCr and EM_GETLINE

    lngLength = SendMessage(hwnd, EM_LINELENGTH, i, 0)

    Return max 109

    However if i set strBuffer = Space$(256) then i'll able to retreive up to 256 char on Call SendMessageStr(hwnd, EM_GETLINE, i, ByVal strBuffer)

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Dec 2005
    Posts
    230

    Re: vbCr and EM_GETLINE

    nope it's not that i want to assign text, it's to retreive text. in the past, i'm able to use the WM_GETTEXT on that richedit however, there's alot of text now so i'll try an alternative way to get text to locate the last vbcr and get the last last beginning that line

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Dec 2005
    Posts
    230

    Re: vbCr and EM_GETLINE

    temporary fix : strBuffer = Space$(1024) '

    Hoppefully that the text it's no longer than 1024.

    the strRichtext don't concatenate the 2 or 3 lines together. don't know why ?

    Is Space(1024) use alot of memory ?

  8. #8
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: vbCr and EM_GETLINE

    I believe line length is not dependent on vbCrLF. If a line contains 150 characters before vbCrLF but wordwrap occurs on the 90th character, then line length returned is 90, not 150.

    Additionally, it appears you are not using EM_GetLine correctly. Per MSDN documentation
    Quote Originally Posted by MSDN
    lParam
    A pointer to the buffer that receives a copy of the line. Before sending the message, set the first word of this buffer to the size, in TCHARs, of the buffer. For ANSI text, this is the number of bytes; for Unicode text, this is the number of characters. The size in the first word is overwritten by the copied line.
    References:
    EM_LineLength: http://msdn2.microsoft.com/en-us/lib...13(VS.85).aspx
    EM_GetLine: http://msdn2.microsoft.com/en-us/lib...84(VS.85).aspx

  9. #9
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: vbCr and EM_GETLINE

    Quote Originally Posted by LaVolpe
    I believe line length is not dependent on vbCrLF...
    It actually depends on either vbCr and vbLf but generally speaking vbNewLine is what should be used - it works better when data is exchanged between different platforms.
    However, setting buffer length may not help - LaVolpe is absolutely right in his observation.

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