VB Textbox Common Problem:Textbox返回第N行的中文文字
Textbox返回第N行的中文文字,在中文XP(Chinese (PRC) as non_Unicode Setting)下可以,但在英文XP(English as non-Unicode Setting)下中文返回问号。迄今为止,还没有发现好的Solution.
测试环境:XP,SP2,English,English as non-Unicode Setting;
SDK API-drawn Unicode Textbox (不是VB自带的ANSI Textbox),VB6,SP6
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 Declare Sub CopyMemory Lib "KERNEL32 " Alias "RtlMoveMemory " (Destination As Any, Source As Any, ByVal Length As Long)
Private Const EM_GETLINE = &HC4
Private Const EM_LINEINDEX = &HBB
Private Const EM_LINELENGTH = &HC1
Public Function GetLineText(ByVal handle As Long, ByVal Index As Long) As String
Dim LineText() As Byte
Dim size As Long
Dim pos As Long
pos = SendMessage(handle, EM_LINEINDEX, Index, 0)
size = SendMessage(handle, EM_LINELENGTH, pos, 0)
If size = 0 Then
GetLineText = " "
Else
ReDim LineText((size - 1) + 1)
CopyMemory LineText(0), size, 2
size = SendMessage(handle, EM_GETLINE, Index, LineText(0))
GetLineText = StrConv(LeftB(LineText, size), vbUnicode)
End If
End Function
[解决办法]
:),解决了的话,就顺便把解决方案贴出来吧