HTML在线编辑器(iframe)能否得到光标所在的行号与列号,谢谢

来源:百度知道 编辑:UC知道 时间:2024/05/31 21:53:21
如题!

能帮忙解决者,再送100分(或加送最大值)

怎么获得文本框中光标所在的行号和列号?
Option Explicit
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
' 注意: 这个消息当行中有选择内容时 , 得到的数是指所选择行的字符总数减去已选择字符数的值
Private Const EM_LINELENGTH = &HC1 ' 用于得到指定行的字符数
Private Const EM_LINEFROMCHAR = &HC9 ' 用于得到指定行的行的行号

'得到整行内容
Public Function GetNowLine() As String
Dim BeginIndex As Integer, EndIndex As Integer
Dim i As Integer, lineNo As Integer
lineNo = GetNowLineNum - 1
BeginIndex = 0
For i = 1 To lineNo
BeginIndex = InStr(BeginIndex + 1, Text1.Text, Chr(10))
Next i
EndIndex = InStr(BeginIndex + 1, Text1.Text, Chr(10))
If EndIndex > 0 Then
GetNowLine = Mid(Text1.Text, BeginIndex + 1, EndIndex - BeginIndex)
Else
GetNowLine = Mid(Text1.Text, BeginIndex + 1, Len(Text1.Text) -