Thread View: comp.lang.basic.misc
3 messages
3 total messages
Started by Jeff Lindborg
Sun, 17 Mar 2002 16:09
Problems displaying Japanese text from a resource DLL
Author: Jeff Lindborg
Date: Sun, 17 Mar 2002 16:09
Date: Sun, 17 Mar 2002 16:09
55 lines
4040 bytes
4040 bytes
I've written (what should be) a fairly simple VB 6 application that will simply display informational text on a form when run. I've generated different DLLs for each language that we support and at startup I check to see which language is the system default and then display the text in that language. No fancy user input issues etc. This works great for all languages except Japanese (and presumably Chinese when we get to supporting it). The resource DLLs were compiled by taking a simple .RC file (with just a few dozen strings in it) and compiling it into a .RES file and then linking that into a DLL. No surprises there. When I open the Japanese resource DLL using C++ on the Japanese OS the strings in the resource table are displayed perfectly. When I run my VB app on that same system, the strings pulled from the DLL are displayed as garbage. I've scoured these news postings for a couple days and I thought I'd covered all the basic rookie missteps here. The fonts/character sets are all set properly on the form. I'm not trying to get fancy by displaying characters that are not in my current code page, I'm not trying to display more than one language at a time etc. I can't figure out for the life of me what I'm missing. Here's the code in question. I would really appreciate any feedback from folks on what I might be doing wrong here. Dim lDLLHandle as long, hr as Long Dim strBuffer as string, strFileName as string strFileName = App.Path + "\resources\JPN\MyRes.dll" strBuffer = String$(100, vbNullChar) lDLLHandle = LoadLibraryExW(StrPtr(strFileName), 0&, DONT_RESOLVE_DLL_REFERENCES Or LOAD_LIBRARY_AS_DATAFILE) hr = LoadStringW(lDLLHandle, lStringID, StrPtr(strBuffer), Len(strBuffer)) 'Setup font and character set of control to write the text to. I've tried removing this 'and manually setting the fonts on the form itself with the same results. MyTextBox.Charset = SHIFTJIS_CHARSET MyTextBox.Name = ChrW(&HFF2D) + ChrW(&HFF33) + ChrW(&H20) + ChrW(&HFF30) + ChrW(&H30B4) + ChrW(&H30B7) + ChrW(&H30C3) + ChrW(&H30AF) MyTextBox.Size = 8 '1041 is the Japanese language code... MyTextBox.text=StrConv(strBuffer,vbUnicode,1041) Do I need to use MultiByteToWideChar to convert the string? It's my understanding that the StrConv function will perform the same task. Is there something else fundamental that I'm missing here? Thanks for any help -Jeff Lindborg@AnswerMonkey.net <mailto:Lindborg@AnswerMonkey.net>
Re: Problems displaying Japanese text from a resource DLL
Author: Ken Halter
Date: Mon, 18 Mar 2002 02:59
Date: Mon, 18 Mar 2002 02:59
78 lines
4308 bytes
4308 bytes
No help here... but you missed the one group that probably has your answers <g> microsoft.public.win32.programmer.international There's a lot of VB questions / answers there. -- Ken Halter MS-MVP-VB Please keep it in the groups.. "Jeff Lindborg" <jlindborg@home.com> wrote in message news:zc3l8.62698$uA5.62265@rwcrnsc51.ops.asp.att.net... > I've written (what should be) a fairly simple VB 6 application that will > simply display informational text on a form when run. I've generated > different DLLs for each language that we support and at startup I check to > see which language is the system default and then display the text in that > language. No fancy user input issues etc. This works great for all > languages except Japanese (and presumably Chinese when we get to supporting > it). > > The resource DLLs were compiled by taking a simple .RC file (with just a few > dozen strings in it) and compiling it into a .RES file and then linking that > into a DLL. No surprises there. When I open the Japanese resource DLL > using C++ on the Japanese OS the strings in the resource table are displayed > perfectly. When I run my VB app on that same system, the strings pulled > from the DLL are displayed as garbage. > > I've scoured these news postings for a couple days and I thought I'd covered > all the basic rookie missteps here. The fonts/character sets are all set > properly on the form. I'm not trying to get fancy by displaying characters > that are not in my current code page, I'm not trying to display more than > one language at a time etc. I can't figure out for the life of me what I'm > missing. > > Here's the code in question. I would really appreciate any feedback from > folks on what I might be doing wrong here. > > Dim lDLLHandle as long, hr as Long > Dim strBuffer as string, strFileName as string > > strFileName = App.Path + "\resources\JPN\MyRes.dll" > strBuffer = String$(100, vbNullChar) > > lDLLHandle = LoadLibraryExW(StrPtr(strFileName), 0&, > DONT_RESOLVE_DLL_REFERENCES Or LOAD_LIBRARY_AS_DATAFILE) > > hr = LoadStringW(lDLLHandle, lStringID, StrPtr(strBuffer), Len(strBuffer)) > > 'Setup font and character set of control to write the text to. I've tried > removing this > 'and manually setting the fonts on the form itself with the same results. > MyTextBox.Charset = SHIFTJIS_CHARSET > MyTextBox.Name = ChrW(&HFF2D) + ChrW(&HFF33) + ChrW(&H20) + ChrW(&HFF30) + > ChrW(&H30B4) + ChrW(&H30B7) + ChrW(&H30C3) + ChrW(&H30AF) > MyTextBox.Size = 8 > > '1041 is the Japanese language code... > MyTextBox.text=StrConv(strBuffer,vbUnicode,1041) > > Do I need to use MultiByteToWideChar to convert the string? It's my > understanding that the StrConv function will perform the same task. Is > there something else fundamental that I'm missing here? > > Thanks for any help > > -Jeff > Lindborg@AnswerMonkey.net <mailto:Lindborg@AnswerMonkey.net> > > >
Re: Problems displaying Japanese text from a resource DLL
Author: Mark Raishbrook
Date: Tue, 19 Mar 2002 22:52
Date: Tue, 19 Mar 2002 22:52
16 lines
1788 bytes
1788 bytes
Hi, Jeff [snip] > Here's the code in question. I would really appreciate any feedback from > folks on what I might be doing wrong here. > MyTextBox.Charset = SHIFTJIS_CHARSET I'm not sure you can use the Charset property directly with a textbox control. Try this instead: MyTextBox.Font.Charset = SHIFTJIS_CHARSET You might also want to check whether you've defined these charset constants properly -- took me ages to find the ones I needed.
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads