15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


Loading strings in a multilingual case

IT347
Tuesday, November 12, 1996


     Environment: MSVC 4.0 / Win95
further env info Win95 swiss German and win95 Swiss French

Hi,
I am having problems using LoadString both the CString and the api   =
version.
In my executable I have Swiss German resources but I also want to be able  =
 =
to give the user the ability to switch to Swiss French. I have created a   =
resource dll containing the French resources and loaded this using   =
Loadlibrary without any problems. If I run the program on a Swiss French   =
win95 then everything is fine BUT and heres the problem if I run the   =
program on a Swiss German version of win95 then although I can select the   =
=
French dll and the menus and dialogs are french as expected LoadString   =
doesnt work, it returns zero length. If I switch back to the german   =
resources everything is hunky dory. I suspect the problem has something   =
todo with the German resources being in the exe and not in a dll as well   =
but I dont know why.
If anyone can shed light on this I would be grateful otherwise I will   =
probably hack out the German stuff into its own dll to see if this helps.





Ian Pepper -- Ian@flexicom.ie
Thursday, November 14, 1996

[Mini-digest: 3 responses]

Hi,

You could put the  Swiss German resources in a resouce only DLL.  But,
your problem is probably due to not setting the resource handle via the
AfxSetResourceHandle/AfxGetResourceHandle in the DLL.

Hope this helps,

Ian


>----------
>From: 	cugr1@gd.swissptt.ch[SMTP:cugr1@gd.swissptt.ch]
>Sent: 	12 November 1996 3:58 PM
>To: 	mfc-l@netcom.com
>Subject: 	Loading strings in a multilingual case
>
>
>     Environment: MSVC 4.0 / Win95
>further env info Win95 swiss German and win95 Swiss French
>
>Hi,
>I am having problems using LoadString both the CString and the api  
>version.
>In my executable I have Swiss German resources but I also want to be
>able   to give the user the ability to switch to Swiss French. I have
>created a   resource dll containing the French resources and loaded
>this using   Loadlibrary without any problems. If I run the program on
>a Swiss French   win95 then everything is fine BUT and heres the
>problem if I run the   program on a Swiss German version of win95 then
>although I can select the   French dll and the menus and dialogs are
>french as expected LoadString   doesnt work, it returns zero length. If
>I switch back to the german   resources everything is hunky dory. I
>suspect the problem has something   todo with the German resources
>being in the exe and not in a dll as well   but I dont know why.
>If anyone can shed light on this I would be grateful otherwise I will  
>probably hack out the German stuff into its own dll to see if this
>helps.
>
>
-----From: dima@ssm6000.samsung.ru (Dulepov Dmitry)

You need to copy _all_ MFC resources from your EXE's RC to your dll=
s (do not forget standart components from AFXRES.RC - they are invi=
sible in AppStudio) and call AfxSetResourceHandle() in the beginnin=
g of InitInstance() to set the resource handle used by MFC to your =
DLL.


Dmitry A. Dulepov
Samsung Electronics Co., Ltd.
Russian Research Center
Phone: +7 (095) 213-9207
Fax: +7 (095) 213-9196
E-mail: dima@src.samsung.ru
-----From: Dan Jerghiuta 

I can't tell you what is wrong as long I don't how you implemented the dlls.
But this is not the usual way to handle multilingual strings.

In MSVC 4.0, you can create the same resource for different languages. So,
you have all your resources in the .EXE file and you don't need other dlls.
One of these lanuages is considered as default for your project (resource
compile option). Once you created all resources for your default language,
you can use Insert-copy command to create a copy of them for another language.

When you run the application, LoadString (both versions) will try to
identify the version of the resource that fits with the language set in the
Control Panel. If there is no such version, the default language version is
used.

So, to switch between the two languages the user has to change the control
pannel language setting. You shouldn't need other tricks unless your client
*really* wants to have all Windows applications in one language and your
application in another language.

BTW, when you create a resource in MSVC, it is implicitly for the language
currently selected in Control Pannel. Maybe this was a problem in your
situation (just guessing).

Dan Jerghiuta
danjer@POBoxes.com





| Вернуться в корень Архива |