i have these code for get the cursor position, but i get bad results:(
these code do the job, but sometimes i don't get the actual position:(
(when moves to next line, the X position isn't correct, seems that new line is like be 2 characters instead 1.. something like)
can anyone advice me?
Code:
Private Sub CheckPosition()
Dim start_pos As Long
Dim end_pos As Long
Dim row As Long
Dim col As Long
SendMessageReferenceParams _
RichTextBox1.hwnd, EM_GETSEL, start_pos, end_pos
row = SendMessage(RichTextBox1.hwnd, EM_LINEFROMCHAR, _
start_pos, 0) + 1
col = start_pos - SendMessage(RichTextBox1.hwnd, EM_LINEINDEX, _
-1, 0) + 1
Label1.Caption = "(" & Format$(row) & ", " & _
Format$(col) & ")"
End Sub
Private Sub RichTextBox1_KeyDown(KeyCode As Integer, Shift As Integer)
Call CheckPosition
End Sub
(when moves to next line, the X position isn't correct, seems that new line is like be 2 characters instead 1.. something like)
can anyone advice me?