'********************************************************** *********** 'Function: Take the TEXTBOX, RICHTEXTBOX cursor and columns
'Support for Chinese, a Chinese character considered a' have questions, please write to me 'Author: Matrix' e-mail: ASPBIT@163.COM'2003-01-24 Fixed sloppy mistakes' ********** ***********************************************************
Option expedition
Public const wm_user = & h400public const em_exgetsel = WM_USER 52
Public const EM_LINEFROMCHAR = & hc9public const em_lineindex = & hbbpublic const em_getsel = & hb0
Public Type Charrange CPMIN As Long Cpmax as Longend Type
Public Type Pointapi X as long y as longed type
Public Declare Function SendMessage Lib "User32" Alias _ "SendMessagea" (Byval Hwnd As Long, Byval WParam As Long, LParam as Any) As long
Public Declare Sub CopyMemory Lib "kernel32" Alias _ "RTLMoveMemory" (PDS AS ANY, PSRC As Any, _ Byval Bytelen As Long)
Rows' and columns of the cursor made Public Function GetCurPos (ByRef TextControl As Control) As POINTAPI Dim LineIndex As Long Dim SelRange As CHARRANGE Dim TempStr As String Dim TempArray () As Byte Dim CurRow As Long Dim CurPos As POINTAPI
Temparray = strconv (TextControl.Text, vbfromunicode)
'Location of the currently selected text Suitable for RichtextBox' TextControl with EM_GETSEL message CALL SendMessage (TextControl.hwnd, em_exgetsel, 0, selrange)
'Returns the line number whose character is located based on the character position specified by the parameter wPARAM (TextControl.hwnd, EM_LINEFROMCHAR, SELRANGE.CPMIN, 0)
'Get the position of the first character of the specified line lineIndex = sendMessage (TextControl.hwnd, EM_LINEINDEX, CURROW, 0)
IF selrange.cpmin = lineindex the getcurpos.x = 1 ELSE
Tempstr = String (Selrange.cpmin - LineIndex, 13) 'Copy the current line Start to Select Text CopyMemory Byval Strptr (Tempstr), ByVal Strptr (Temparray) LineIndex, Selrange.cpmin - LineIndex Temparray = Tempstr
'Remove useless information Redim Preserve Temparray (Selrange.cpmin - LineIndex - 1)
'Convert to Unicode Tempstr = STRCONV (Temparray, Vbunicode)
GetCurpos.x = len (Tempstr) 1 end if getcurpos.y = Currow 1END FUNCTION