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

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


AW: Loading strings in a multilingual ca

IT347
Sunday, November 17, 1996


Tbanks for all the responses to this question but unfortunately no one   =
has answered the question. I guess I didnt pose it correctly

Why when I switch to using resources from a dll and not from an exe cant   =
=
I load the string table ALL the other resources load ok, ie menus and   =
dialogs? This situation only occurs when the language setting of the os   =
matches the language used in the resources compiled into the exe.

Please note as all the other resources load I must have some point have   =
successfully done a AfxSetInstanceHandle. Also I have tried using the api   =
=
loadstring resource with the instance handle of the dll.
Also telling the user to change the control panel settings doesnt work   =
cause the requirement is to only change this programs language.

regards


 ----------
Von:  Ian Pepper=5BSMTP:Ian=40flexicom.ie=5D
Gesendet:  Donnerstag, 14. November 1996 10:45
An:  'mfc-l=40netcom.com'
Betreff:  RE: Loading strings in a multilingual case

=5BMini-digest: 3 responses=5D

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=40gd.swissptt.ch=5BSMTP:cugr1=40gd.swissptt.ch=5D
>Sent:  12 November 1996 3:58 PM
>To:  mfc-l=40netcom.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=40ssm6000.samsung.ru (Dulepov Dmitry)

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


Dmitry A. Dulepov
Samsung Electronics Co., Ltd.
Russian Research Center
Phone: +7 (095) 213-9207
Fax: +7 (095) 213-9196
E-mail: dima=40src.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=40POBoxes.com





Dan Jerghiuta -- danjer@POBoxes.com
Wednesday, November 20, 1996

Sorry for not being helpful. If you really need to switch yourself the 
resources, then forget about the usual way. 

Simply create resource-only DLLs for each language and do not let any 
resources in the EXE. Use LoadLibraryEx with LOAD_LIBRARY_AS_DATAFILE
to load the needed DLL and unload it before loading another one.
Declare the resources in each DLL as default language.

In NT (and I think it's also true in 95) all resources from the DLL
are maped in the EXE. Passing the handle of the DLL to a Load... function
does not help. That's why I recomend you to remove all the resources from
the EXE once you choose this approach.

BTW, maybe your problem has something to do with the fact that an application 
may have multiple dialogs, menus etc, but only one string table.

Dan Jerghiuta
danjer@POboxes.com

At 12:33 PM 11/17/96 +0100, you wrote:
>
>Tbanks for all the responses to this question but unfortunately no one
has answered the question. I guess I didnt pose it correctly
>
>Why when I switch to using resources from a dll and not from an exe cant
I load the string table ALL the other resources load ok, ie menus and
dialogs? This situation only occurs when the language setting of the os
matches the language used in the resources compiled into the exe.
>
>Please note as all the other resources load I must have some point have
successfully done a AfxSetInstanceHandle. Also I have tried using the api
loadstring resource with the instance handle of the dll.
>Also telling the user to change the control panel settings doesnt work
cause the requirement is to only change this programs language.
>
>regards
>





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