How to Display the Cursor’s coordinates of a Rich Text Box
Posted on January 4, 2009
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | 'Controls - How to Display the Cursor's coordinates of a Rich Text Box Option Explicit Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, _ ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Any) As Long Public Const WM_USER = &H400 Public Const EM_EXLINEFROMCHAR = (WM_USER + 54) Public Const EM_LINEINDEX = &HBB Public Function GetCoOrdinates(rtf As RichTextBox) As String Dim lLine As Long lLine = SendMessage(rtf.hWnd, EM_EXLINEFROMCHAR, ByVal CLng(0), ByVal CLng(rtf.SelStart)) GetCoOrdinates = CStr(rtf.SelStart - SendMessage(rtf.hWnd, EM_LINEINDEX, ByVal lLine, ByVal CLng(0)) + 1) + ":" + CStr(lLine + 1) End Function |