' 获得文本框中某一行的内容
' hwnd 为文本框的句柄, Line 为文本框中的行号
Function GetTextLines(ByVal hwnd As Long, ByVal Line As Long) As String
Dim length As Long, bArr() As Byte, bArr2() As Byte, lc As Long
lc = SendMessage(hwnd, EM_LINEINDEX, Line - 1, ByVal 0&)
length = SendMessage(hwnd, EM_LINELENGTH, lc, ByVal 0&)
If length > 0 Then
ReDim bArr(length + 1) As Byte, bArr2(length - 1) As Byte
Call RtlMoveMemory(bArr(0), length, 2)
Call SendMessage(hwnd, EM_GETLINE, Line - 1, bArr(0))
Call RtlMoveMemory(bArr2(0), bArr(0), length)
GetTextLines = StrConv(bArr2, vbUnicode)
Else
GetTextLines = ""
End If
End Function
' 获得文本框中的行数
' hwnd 为文本框的句柄
Function GetTextRowCount(ByVal hwnd As Long) As Long
GetTextRowCount = SendMessageBynum(hwnd, EM_GETLINECOUNT, 0, 0&)
End Function