首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VB >

VB Textbox Common Problem:Textbox返回第N行的中文文字解决办法

2012-01-26 
VB Textbox Common Problem:Textbox返回第N行的中文文字Textbox返回第N行的中文文字,在中文XP(Chinese(PRC

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

[解决办法]
:),解决了的话,就顺便把解决方案贴出来吧

热点排行