Identifying Cursor Row/Col position... 
Author Message
 Identifying Cursor Row/Col position...

Hi there,

I was wandering if anyone can advise me if there is an API, or another way,
of identifying the Cursor Row/Col position. With this I don't meanthe Mouse
cursor, but rather the text cursor in a TEXT boX (rtfTEXT).

Much appreciated

Regards

Theo

--
COBOL lives...



Sun, 02 Dec 2001 03:00:00 GMT  
 Identifying Cursor Row/Col position...

Quote:
>I was wandering if anyone can advise me if there is an API, or another way,
>of identifying the Cursor Row/Col position. With this I don't meanthe Mouse
>cursor, but rather the text cursor in a TEXT boX (rtfTEXT).

Put the following declarations in the General Declarations section of a form:

Private Declare Function SendMessage Lib "user32" Alias _
    "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, _
    ByVal wParam As Long, lParam As Any) As Long
Const EM_LINEFROMCHAR = &HC9
Const EM_LINEINDEX = &HBB

The following code puts the Row/Col position in a Label:

    Dim lLine As Long, lIndex As Long
            'Get the current line
    lLine = SendMessage(text1.hwnd, EM_LINEFROMCHAR, -1, 0&)
    Label1 = "Line: " & lLine + 1
            'Get the character offset of the first position of the line.
    lIndex = SendMessage(text1.hwnd, EM_LINEINDEX, -1, 0&)
            'Calculate the position of the cursor on the line.
    Label1 = Label1 & "  Pos: " & (text1.SelStart - lIndex + 1)

Lee Weiner
weiner AT fuse DOT net
http://home.fuse.net/lweiner



Sun, 02 Dec 2001 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Getting the Current Row/Col Position in Richtextbox

2. DataGrid - (Row, Col) position is old

3. Listbox: Get row from position of mouse-cursor

4. Help: row and column position of cursor in a text box (asking 3rd time)

5. Help: row and column position of cursor in a text box

6. Weird behavior: Clicking from new row to old row causes cursor to jump to col 0 instead of intended column.

7. Add row to datatable from datagrid without leaving current row with cursor

8. VB Record Set as (row,col) array?

9. How to set total number of col and row in DBGrid

10. DBGrid how to set num col, rows

11. : Grid Col/Row Resizing

12. Moving the row and col of FlexGrid

 

 
Powered by phpBB® Forum Software