Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Loading Language Resource DLLs

306 views
Skip to first unread message

neel...@rediffmail.com

unread,
Sep 28, 2008, 5:46:51 AM9/28/08
to
Hi,

The recommended way of loading a resource dll is in
CWinApp::InitInstance but in CWinApp class declaration you can see
LoadAppLangResourceDLL which is virtual and in the block which
mentions "// overrides for implementation". But in spite of that, it's
not documented anywhere.

Putting the code in InitInstance doesn't hurt but
LoadAppLangResourceDLL is a nice place to load the required library.

Any idea, if it was intentional or accidental and more importantly if
there is a problem in overriding that function (Since it's public and
virtual)?

Thanks in advance,
-Neel.

Mihai N.

unread,
Sep 30, 2008, 3:14:55 AM9/30/08
to

The official way to do that is to load the DLL and then call
AfxSetResourceHandle. And you can do that in InitInstance.
No need to mess-around with LoadAppLangResourceDLL, if it's not documented.


--
Mihai Nita [Microsoft MVP, Visual C++]
http://www.mihai-nita.net
------------------------------------------
Replace _year_ with _ to get the real email

nob...@nowhere.com

unread,
Sep 30, 2008, 7:48:12 AM9/30/08
to
>> The recommended way of loading a resource dll is in
>> CWinApp::InitInstance but in CWinApp class declaration you can see
>> LoadAppLangResourceDLL which is virtual and in the block which
>> mentions "// overrides for implementation". But in spite of that, it's
>> not documented anywhere.
>>
>> Putting the code in InitInstance doesn't hurt but
>> LoadAppLangResourceDLL is a nice place to load the required library.
>>
>> Any idea, if it was intentional or accidental and more importantly if
>> there is a problem in overriding that function (Since it's public and
>> virtual)?
>
> The official way to do that is to load the DLL and then call
> AfxSetResourceHandle. And you can do that in InitInstance.
> No need to mess-around with LoadAppLangResourceDLL, if it's not
> documented.

Guys,

You are talking about resources in dll, maybe you know why dll with multiple
resources (multiple rc files) can not be linked with option "Use MFC in a
Static Library" - it reports error:

CVTRES : fatal error CVT1100: duplicate resource. type:CURSOR, name:13,
language:0x0409

I don't have any resource of type CURSOR in my rc files.

Thanks,
Arek.


Serge Wautier

unread,
Oct 1, 2008, 11:00:19 AM10/1/08
to
Neel,

not a straight answer to your question but this CodeProject article (of
mine! ;-) implements a solution that so far works well for me.

http://www.codeproject.com/KB/locale/LanguageMenu.aspx

My 2-cents,

Serge.
http://www.apptranslator.com - Localization tool for your MFC applications


<neel...@rediffmail.com> wrote in message
news:dd866d89-77e8-4bb5...@v39g2000pro.googlegroups.com...

Mihai N.

unread,
Oct 2, 2008, 12:27:07 AM10/2/08
to
> You are talking about resources in dll, maybe you know why dll with
> multiple
> resources (multiple rc files) can not be linked with option "Use MFC in a
> Static Library" - it reports error:
>
> CVTRES : fatal error CVT1100: duplicate resource. type:CURSOR, name:13,
> language:0x0409
>
> I don't have any resource of type CURSOR in my rc files.

If you have rc files for MFC, they usually include mfc resources
(stuff like afxres.rc or afxprint.rc)
So if you have more than one .rc file including the same afx*.rc
then that's a conflict right there.

If you explain what are you trying to achieve with several .rc files
in the same dll we might be able to come up with another way to do it.

nob...@nowhere.com

unread,
Oct 2, 2008, 11:48:08 AM10/2/08
to
> If you have rc files for MFC, they usually include mfc resources
> (stuff like afxres.rc or afxprint.rc)
> So if you have more than one .rc file including the same afx*.rc
> then that's a conflict right there.
>
> If you explain what are you trying to achieve with several .rc files
> in the same dll we might be able to come up with another way to do it.

Thanks for your answer. I have 3 apps in 3 exe files. To avoid dependecies
with MFC dlls I use statically linked MFC.

I created another project, copied all rc files, build dll. I use
AfxSetResourceHandle to localize my apps. It works fine in Debug when MFC is
in shared dlls, in Release version, when MFC is statically linked - compile
fails.

Maybe there is better way to create multinanguage apps.

Thanks,
Arek.


David Ching

unread,
Oct 2, 2008, 12:31:45 PM10/2/08
to
<neel...@rediffmail.com> wrote in message
news:dd866d89-77e8-4bb5...@v39g2000pro.googlegroups.com...
> Hi,
>
> The recommended way of loading a resource dll is in
> CWinApp::InitInstance but in CWinApp class declaration you can see
> LoadAppLangResourceDLL which is virtual and in the block which
> mentions "// overrides for implementation". But in spite of that, it's
> not documented anywhere.
>

See http://msdn.microsoft.com/en-us/magazine/cc163557.aspx for a good intro
to satellite DLL's.

-- David


Mihai N.

unread,
Oct 3, 2008, 12:50:46 AM10/3/08
to
> Thanks for your answer. I have 3 apps in 3 exe files. To avoid dependecies
> with MFC dlls I use statically linked MFC.
> I created another project, copied all rc files, build dll. I use
> AfxSetResourceHandle to localize my apps. It works fine in Debug when MFC
> is
> in shared dlls, in Release version, when MFC is statically linked - compile
> fails.
>
> Maybe there is better way to create multinanguage apps.

I am not sure what multilingual has to do with it.
Are the 3 .rc files you copy in 3 different languages?

If that is the case, the recomended way is to compile each language
in a separate resource-only dll. This is consistent with you saying
that you use AfxSetResourceHandle.

It is also possible that each resource file is in a different language
and compile them all in your application. If that's what you are trying
to do, it is ok, but you don't need AfxSetResourceHandle.

So I don't understand what you are trying.


But instead of waiting for a clarification, I will guess that
the 3 .rc files are in 3 languages, and you want (for some reason)
to have them all in the same file.

In this case you will have to tag each .rc with a different language.
This can be done with the LANGUAGE directive inside the .rc file,
or with /l switch for the resource compiler

But take care, the LANGUAGE directive in the file overrides the switch.
So if every file has a LANGUEGE directive inside saying ENGLISH then
the conflict will remain, because the switch is ignored.


If every resource file is tagged with a different language you will have
no conflict, because cursor 3 in French does not conflict with a cursor 3
in English.
But don't use this as a work-around for 3 English files please :-)

See also here:
http://www.mihai-nita.net/article.php?artID=20070503a

0 new messages