Tweet
|
wwnavi_string.rc ... #pragma code_page(1252) STRINGTABLE BEGIN 101 "My Name" // MsgBox ("My Name"), MyClass.cls 102 "Form1" // Caption = "Form1", Form1.frm 103 "MS PGothic" // Name = "MS PGothic", Form1.frm 104 "Button1" // Caption = "Button1", Form1.frm 105 "@Arial Unicode MS" // Name = "@Arial Unicode MS", Form1.frm 106 "Label1" // Caption = "Label1", Form1.frm 107 "Ms Mincho" // Name = "Ms Mincho", Form1.frm 108 "array 1" // strs1(0) = "array 1", Form1.frm 109 "array 2" // strs2(0) = "array 2", Form1.frm 110 "Hello, how are you? This is sample for Windows DLL." // MsgBox ("Hello, how are you? This is sample for Windows DLL."), Form1.frm 111 "this is simple text." // msg = "this is simple text.", Module1.bas 112 "This is message 2." // MsgBox ("This is message 2."), Module1.bas END*Code pages and file encodings have to corresponding to each other.
Private Declare Function GetThreadLocale Lib "kernel32" () As Long Private Declare Function GetUserDefaultLCID Lib "kernel32" () As Long Private Declare Function GetLocaleInfo Lib "kernel32" Alias "GetLocaleInfoA" _ (ByVal Locale As Long, ByVal LCType As Long, ByVal lpLCData As String, _ ByVal cchData As Long) As Long Private Declare Function LoadLibrary Lib "kernel32" Alias "LoadLibraryA" _ (ByVal lpLibFileName As String) As Long Private Declare Function LoadString Lib "user32" Alias "LoadStringA" _ (ByVal hInstance As Long, ByVal wID As Long, ByVal lpBuffer As String, _ ByVal nBufferMax As Long) As Long Private Const LOCALE_IDEFAULTANSICODEPAGE = &H1004& Private Const LOCALE_SISO639LANGNAME = &H59GetThreadLocale, GetUserDefaultLCID ... Get the current locale.
MsgBox (wwnaviGetString(110))
...
Function WwnaviGetString(id As Long) As String
Dim buf As String * 512
Dim rslt As Long
rslt = LoadString(wwnaviH, id, buf, 512)
WwnaviGetString = buf
End Function
wwnaviH ... Pointer to DLL modules (described later).
Private wwnaviH As Long Function WwnaviLoadLibrary() As Long Dim libName As String Dim langName As String * 10 Dim langName2 As String Dim lcId As Long Dim rslt As Long Dim posNull As Long Dim cnt As Integer Dim i As Integer 'lcId = GetThreadLocale() lcId = GetUserDefaultLCID() rslt = GetLocaleInfo(lcId, LOCALE_SISO639LANGNAME, langName, 10) posNull = InStr(langName, Chr$(0)) langName = Left$(langName, posNull - 1) langName2 = "" cnt = Len(langName) For i = 1 To cnt If Mid(langName, i, 1) <> " " Then langName2 = langName2 & Mid(langName, i, 1) End If Next i libName = "./" & langName2 & "/wwnavi_string_VBTest.dll" wwnaviH = LoadLibrary(libName) If wwnaviH = 0 Then wwnaviH = LoadLibrary("./wwnavi_string_VBTest.dll") End If WwnaviLoadLibrary = wwnaviH End Function Function WwnaviGetModule() As Long WwnaviGetModule = wwnaviH End Function Function WwnaviGetString(id As Long) As String Dim buf As String * 512 Dim rslt As Long If WwnaviGetModule() = 0 Then WwnaviLoadLibrary(*1) End If rslt = LoadString(wwnaviH, id, buf, 512) WwnaviGetString = buf End FunctionwwnaviH ... Pointer to the DLL modules.
Form1.frm ... VERSION 5.00 Begin VB.Form Form1 Caption = "Form1" ClientHeight = 1530 ... BeginProperty Font Name = "MS PGothic" (*1) Size = 8.25 ... Private Sub Form_Load() WwnaviSetCaption End Sub Private Sub WwnaviSetCaption() Form1.Caption = wwnaviGetString(102) ' "Form1" 'Form1.Font.Name = "Lucida Sans Unicode" Form1.Font.Name = wwnaviGetString(103) (*2) ' "MS PGothic" Command1.Caption = wwnaviGetString(104) ' "Button1" 'Command1.Font.Name = "Lucida Sans Unicode" Command1.Font.Name = wwnaviGetString(105) ' "@Arial Unicode MS" Label1.AutoSize = True Label1.Font.Charset = WwnaviGetCharSet(WwnaviGetCodePage) Label1.Caption = wwnaviGetString(106) ' "Label1" 'Label1.Font.Name = "Lucida Sans Unicode" Label1.Font.Name = wwnaviGetString(107) ' "Ms Mincho" End Sub*1)Default font set by IDE. These are auto-generated codes and you cannot edit manually.
./Foo.exe ... executable file ./wwnavi_string.rc -> ./wwnavi_string.res -> ./wwnavi_string.dll ... <- * default DLL ./wwnavi_string_ja.rc -> ./wwnavi_string_ja.res -> ./ja/wwnavi_string.dll ... <- * Japanese DLL
Go to Internationalization Programming Top