🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.basic.misc
Article #132

Problems displaying Japanese text from a resource DLL

#132
From: Jeff Lindborg
Date: Sun, 17 Mar 2002 16:09
55 lines
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>
Technical Details
Message-ID: <zc3l8.62698$uA5.62265@rwcrnsc51.ops.asp.att.net>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!canoe.uoregon.edu!logbridge.uoregon.edu!arclight.uoregon.edu!wn14eed!worldnet.att.net!204.127.198.203!attbi_feed3!attbi.com!rwcrnsc51.ops.asp.att.net.POSTED!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10c949,a9f62139f478463c,start
X-Google-Attributes: gid10c949,public
X-Google-Thread: 104093,a9f62139f478463c,start
X-Google-Attributes: gid104093,public
X-Google-Thread: 100d42,a9f62139f478463c,start
X-Google-Attributes: gid100d42,public
X-Google-Thread: 108062,a9f62139f478463c,start
X-Google-Attributes: gid108062,public
X-Google-Thread: 11493c,a9f62139f478463c,start
X-Google-Attributes: gid11493c,public
X-Google-ArrivalTime: 2002-03-17 08:09:03 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!canoe.uoregon.edu!logbridge.uoregon.edu!arclight.uoregon.edu!wn14eed!worldnet.att.net!204.127.198.203!attbi_feed3!attbi.com!rwcrnsc51.ops.asp.att.net.POSTED!not-for-mail
From: "Jeff Lindborg" <jlindborg@home.com>
Newsgroups: comp.lang.basic.misc,cz.comp.lang.basic.visual,microsoft.public.basic.other,microsoft.public.vb.general.discussion,microsoft.public.vb.winapi
Subject: Problems displaying Japanese text from a resource DLL
Lines: 58
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.50.4807.1700
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4807.1700
Message-ID: <zc3l8.62698$uA5.62265@rwcrnsc51.ops.asp.att.net>
NNTP-Posting-Host: 12.228.110.188
X-Complaints-To: abuse@attbi.com
X-Trace: rwcrnsc51.ops.asp.att.net 1016381343 12.228.110.188 (Sun, 17 Mar 2002 16:09:03 GMT)
NNTP-Posting-Date: Sun, 17 Mar 2002 16:09:03 GMT
Organization: AT&T Broadband
Date: Sun, 17 Mar 2002 16:09:03 GMT