怎样使一个在简体中文环境下编写的程序,在繁体中文下能正常显示繁体字(不要用资源文件或列表文件,只用API)下面的代码我在简体中编译后,放在繁体系统中使用个别字出现(?)问号,特来寻求高人
Option Explicit'VB中简单实现繁体简体互转Private Declare Function LCMapString Lib "kernel32" Alias "LCMapStringA" (ByVal Locale As Long, ByVal dwMapFlags As Long, ByVal lpSrcStr As String, ByVal cchSrc As Long, ByVal lpDestStr As String, ByVal cchDest As Long) As Long
Private Declare Function lstrlen Lib "kernel32" Alias "lstrlenA" (ByVal lpString As String) As Long
Private Declare Function GetSystemDefaultLCID Lib "kernel32" () As Long
Private OsType As LongPrivate Function ChangeISN(ByVal Str As String, ByVal bLa As Boolean) As String
If OsType <> &H404 Then ChangeISN = Str: Exit Function
Dim bg() As Byte
If bLa Then
bg = StrConv(Str, vbFromUnicode, &H804)
Str = StrConv(bg, vbUnicode, &H404)
Else
bg = StrConv(Str, vbFromUnicode, &H404)
Str = StrConv(bg, vbUnicode, &H804)
End If
ChangeISN = Str
End FunctionPrivate Function AutoFt(ByVal Str As String) As String
Str = ChangeISN(Str, True)
Str = JtToFt(Str)
AutoFt = ChangeISN(Str, False)
End FunctionPublic Function GetOsType() As String
Dim ret As String
OsType = GetSystemDefaultLCID
Select Case Hex(OsType)
Case 804:
ret = "中文简体(大陆)"
Case 404:
ret = AutoFt("中文繁体(台湾)")
Case 409:
ret = "English"
Case Else:
ret = "Other Language"
End Select
GetOsType = ret
End Function'简转繁
Public Function JtToFt(ByVal Str As String) As String
Dim STlen As Long
Dim STf As String
STlen = lstrlen(Str)
STf = Space(STlen)
LCMapString &H804, &H4000000, Str, STlen, STf, STlen
JtToFt = STf
End Function'繁转简
Public Function FtToJt(ByVal Str As String) As String
Dim STlen As Long
Dim STj As String
STlen = lstrlen(Str)
STj = Space(STlen)
LCMapString &H804, &H2000000, Str, STlen, STj, STlen
FtToJt = STj
End FunctionPrivate Sub Form_Load()
GetOsType
End SubPrivate Sub Command1_Click()
MsgBox AutoFt("中国共产党;记录;才能调节"), vbOKOnly, AutoFt("简转繁测试")
End Sub
Option Explicit'VB中简单实现繁体简体互转Private Declare Function LCMapString Lib "kernel32" Alias "LCMapStringA" (ByVal Locale As Long, ByVal dwMapFlags As Long, ByVal lpSrcStr As String, ByVal cchSrc As Long, ByVal lpDestStr As String, ByVal cchDest As Long) As Long
Private Declare Function lstrlen Lib "kernel32" Alias "lstrlenA" (ByVal lpString As String) As Long
Private Declare Function GetSystemDefaultLCID Lib "kernel32" () As Long
Private OsType As LongPrivate Function ChangeISN(ByVal Str As String, ByVal bLa As Boolean) As String
If OsType <> &H404 Then ChangeISN = Str: Exit Function
Dim bg() As Byte
If bLa Then
bg = StrConv(Str, vbFromUnicode, &H804)
Str = StrConv(bg, vbUnicode, &H404)
Else
bg = StrConv(Str, vbFromUnicode, &H404)
Str = StrConv(bg, vbUnicode, &H804)
End If
ChangeISN = Str
End FunctionPrivate Function AutoFt(ByVal Str As String) As String
Str = ChangeISN(Str, True)
Str = JtToFt(Str)
AutoFt = ChangeISN(Str, False)
End FunctionPublic Function GetOsType() As String
Dim ret As String
OsType = GetSystemDefaultLCID
Select Case Hex(OsType)
Case 804:
ret = "中文简体(大陆)"
Case 404:
ret = AutoFt("中文繁体(台湾)")
Case 409:
ret = "English"
Case Else:
ret = "Other Language"
End Select
GetOsType = ret
End Function'简转繁
Public Function JtToFt(ByVal Str As String) As String
Dim STlen As Long
Dim STf As String
STlen = lstrlen(Str)
STf = Space(STlen)
LCMapString &H804, &H4000000, Str, STlen, STf, STlen
JtToFt = STf
End Function'繁转简
Public Function FtToJt(ByVal Str As String) As String
Dim STlen As Long
Dim STj As String
STlen = lstrlen(Str)
STj = Space(STlen)
LCMapString &H804, &H2000000, Str, STlen, STj, STlen
FtToJt = STj
End FunctionPrivate Sub Form_Load()
GetOsType
End SubPrivate Sub Command1_Click()
MsgBox AutoFt("中国共产党;记录;才能调节"), vbOKOnly, AutoFt("简转繁测试")
End Sub
你先不要显示在Msgbox内,先用控件显示,然后设置控件的字体试试.