I been scouring the Internet for an answer to my problem, and a couple of times thought I had almost found the answer, but still to no avail.
I'm tying to use the Rich Edit class (riched20.dll), to display unicode text. The riched20.dll file is loaded by using the LoadLibrary function, and a Rich Edit control created with the CreateWindowEx function. The text is input into a string variable from a unicode text file. The text is then inserted into the control, by using the SendMessage function and the WM_SETTEXT message. The font is set after the text has been inserted by using the WM_SETFONT message, which uses the form's font.
[CODE=vb]
Private Declare Function CreateWindowEx Lib "user32.dll " Alias "CreateWindowEx A" (ByVal dwExStyle As Long, ByVal lpClassName As String, ByVal lpWindowName As String, ByVal dwStyle As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hWndParent As Long, ByVal hMenu As Long, ByVal hInstance As Long, ByRef lpParam As Any) As Long
Private Declare Function GetCurrentObjec t Lib "gdi32.dll" (ByVal hDC As Long, ByVal uObjectType As Long) As Long
Private Declare Function LoadLibrary Lib "kernel32.d ll" Alias "LoadLibrar yA" (ByVal lpLibFileName As String) As Long
Private Declare Function SendMessage Lib "user32.dll " Alias "SendMessag eA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByRef lParam As Any) As Long
Private Declare Function SendMessageStri ng Lib "user32.dll " Alias "SendMessag eA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As String) As Long
Private Const ES_MULTILINE As Long = &H4
'Private Const ES_READONLY As Long = &H800
Private Const OBJ_FONT As Long = 6
Private Const ST_DEFAULT As Long = 0
Private Const WM_SETFONT As Long = &H30
Private Const WM_SETTEXT As Long = &HC
Private Const WM_USER As Long = &H400
Private Const EM_SETTEXTMODE As Long = (WM_USER + 89)
Private Const EM_SETTEXTEX As Long = (WM_USER + 97)
Private Const WS_CHILD As Long = &H40000000
Private Const WS_VISIBLE As Long = &H10000000
Private Const WS_VSCROLL As Long = &H200000
Private Const WS_EX_CLIENTEDG E As Long = &H200&
Private hFont As Long
Private hRich As Long
Private hWndRich As Long
Private Sub Form_Load()
hRich = LoadLibrary("ri ched20.dll")
Line Input #1, TempStr
For I = 1 To 6
Line Input #1, TempStr
lblDictAboutInf o(I) = TempStr
Next I
I = 0
Do Until TempStr = "[Notes]"
Line Input #1, TempStr
Loop
TempStr = vbNullString
TempStr2 = vbNullString
Line Input #1, TempStr
Do
TempStr2 = TempStr2 & (TempStr & vbCrLf)
Line Input #1, TempStr
Loop Until TempStr = "[Abbreviations]"
hWndRich = CreateWindowEx( WS_EX_CLIENTEDG E, "RichEdit20 W", vbNullString, ES_MULTILINE Or ES_READONLY Or WS_CHILD Or WS_VISIBLE Or WS_VSCROLL, 9, 152, 476, 214, hWnd, 0, App.hInstance, 0)
SendMessageStri ng hWndRich, WM_SETTEXT, 0, TempStr2
hFont = GetCurrentObjec t(hDC, OBJ_FONT)
SendMessage hWndRich, WM_SETFONT, hFont, 1
TempStr = vbNullString
TempStr2 = vbNullString
Seek #1, 1
End Sub
[/CODE]
The majority of the text works fine, but there are special unicode characters that aren't displayed properly within the text. The font is set to Verdana, which should work with Unicode characters. I understand that version 1 of the Rich Edit class doesn't support Unicode, but version 2 or higher should.
I'm using Visual Basic 6, and Windows XP.
I'm tying to use the Rich Edit class (riched20.dll), to display unicode text. The riched20.dll file is loaded by using the LoadLibrary function, and a Rich Edit control created with the CreateWindowEx function. The text is input into a string variable from a unicode text file. The text is then inserted into the control, by using the SendMessage function and the WM_SETTEXT message. The font is set after the text has been inserted by using the WM_SETFONT message, which uses the form's font.
[CODE=vb]
Private Declare Function CreateWindowEx Lib "user32.dll " Alias "CreateWindowEx A" (ByVal dwExStyle As Long, ByVal lpClassName As String, ByVal lpWindowName As String, ByVal dwStyle As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hWndParent As Long, ByVal hMenu As Long, ByVal hInstance As Long, ByRef lpParam As Any) As Long
Private Declare Function GetCurrentObjec t Lib "gdi32.dll" (ByVal hDC As Long, ByVal uObjectType As Long) As Long
Private Declare Function LoadLibrary Lib "kernel32.d ll" Alias "LoadLibrar yA" (ByVal lpLibFileName As String) As Long
Private Declare Function SendMessage Lib "user32.dll " Alias "SendMessag eA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByRef lParam As Any) As Long
Private Declare Function SendMessageStri ng Lib "user32.dll " Alias "SendMessag eA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As String) As Long
Private Const ES_MULTILINE As Long = &H4
'Private Const ES_READONLY As Long = &H800
Private Const OBJ_FONT As Long = 6
Private Const ST_DEFAULT As Long = 0
Private Const WM_SETFONT As Long = &H30
Private Const WM_SETTEXT As Long = &HC
Private Const WM_USER As Long = &H400
Private Const EM_SETTEXTMODE As Long = (WM_USER + 89)
Private Const EM_SETTEXTEX As Long = (WM_USER + 97)
Private Const WS_CHILD As Long = &H40000000
Private Const WS_VISIBLE As Long = &H10000000
Private Const WS_VSCROLL As Long = &H200000
Private Const WS_EX_CLIENTEDG E As Long = &H200&
Private hFont As Long
Private hRich As Long
Private hWndRich As Long
Private Sub Form_Load()
hRich = LoadLibrary("ri ched20.dll")
Line Input #1, TempStr
For I = 1 To 6
Line Input #1, TempStr
lblDictAboutInf o(I) = TempStr
Next I
I = 0
Do Until TempStr = "[Notes]"
Line Input #1, TempStr
Loop
TempStr = vbNullString
TempStr2 = vbNullString
Line Input #1, TempStr
Do
TempStr2 = TempStr2 & (TempStr & vbCrLf)
Line Input #1, TempStr
Loop Until TempStr = "[Abbreviations]"
hWndRich = CreateWindowEx( WS_EX_CLIENTEDG E, "RichEdit20 W", vbNullString, ES_MULTILINE Or ES_READONLY Or WS_CHILD Or WS_VISIBLE Or WS_VSCROLL, 9, 152, 476, 214, hWnd, 0, App.hInstance, 0)
SendMessageStri ng hWndRich, WM_SETTEXT, 0, TempStr2
hFont = GetCurrentObjec t(hDC, OBJ_FONT)
SendMessage hWndRich, WM_SETFONT, hFont, 1
TempStr = vbNullString
TempStr2 = vbNullString
Seek #1, 1
End Sub
[/CODE]
The majority of the text works fine, but there are special unicode characters that aren't displayed properly within the text. The font is set to Verdana, which should work with Unicode characters. I understand that version 1 of the Rich Edit class doesn't support Unicode, but version 2 or higher should.
I'm using Visual Basic 6, and Windows XP.
Comment