Results 1 to 8 of 8

Thread: get line number

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2000
    Location
    Birmingham, AL
    Posts
    1,276

    get line number

    How can you get the line number in a multiline text box?

  2. #2
    Frenzied Member
    Join Date
    Jul 2002
    Posts
    1,370
    Code:
    long TextBoxLine = SendMessage( hWnd, EM_LINEINDEX,  (-1),  0L);
    TextboxLine has the current line (one with the caret)
    hWnd is the hWnd of the textbox.

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2000
    Location
    Birmingham, AL
    Posts
    1,276
    I think you need to use the EM_LINEFROMCHAR message to get the line number of the caret.

  4. #4
    Frenzied Member
    Join Date
    Jul 2002
    Posts
    1,370
    Not according to MSDN. This gets the active line

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2000
    Location
    Birmingham, AL
    Posts
    1,276
    I believe you are incorrect.
    from MSDN
    The EM_LINEINDEX message retrieves the character index of the first character of a specified line in a multiline edit control.

    wParam
    Specifies the zero-based line number. A value of –1 specifies the current line number (the line that contains the caret).

    ------------------------------------------------------------------------------

    The EM_LINEFROMCHAR message retrieves the index of the line that contains the specified character index in a multiline edit control.

    wParam
    Specifies the character index of the character contained in the line whose number is to be retrieved. If this parameter is –1, EM_LINEFROMCHAR retrieves either the line number of the current line (the line containing the caret) or, if there is a selection, the line number of the line containing the beginning of the selection.

  6. #6
    Fanatic Member prog_tom's Avatar
    Join Date
    May 2001
    Location
    Los Angeles and Little Rock
    Posts
    810
    what is that "OL" for?

    prog_tom
    JOIN THE REVOLUTION!!!! Dual T3 backedup science community.
    http://physics.sviesoft.com/forum

  7. #7
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    It specifies that you specifically want a "long", not an "int" in the parameter. Almost irrelevant with C++ because it'll coerce the types anyway.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  8. #8

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2000
    Location
    Birmingham, AL
    Posts
    1,276
    it's the same as (long)0
    which is irrelevant as parksie said.

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