Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / May 2005

Tip: Looking for answers? Try searching our database.

How to change the interface language using resource.rc?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Kaworu - 17 May 2005 11:10 GMT
Hi, at first time I want to apologize for my English.

I need to change the language of my app and I like to do it changin
the caption of the controls in the resource.rc file, or having on
resource.rc file for each language, but then I need to use resource.r
file in the execution and not in the compile time, can I do it? How ca
I do it?.

Thank you


Mihai N. - 18 May 2005 04:37 GMT
> Hi, at first time I want to apologize for my English.
No need to :-)

> I need to change the language of my app and I like to do it changing
> the caption of the controls in the resource.rc file, or having one
> resource.rc file for each language, but then I need to use resource.rc
> file in the execution and not in the compile time, can I do it? How can
> I do it?.
You do not use the .rc at runtime, you use the resources compiled in a DLL.

How to to it:

1. Create a resource only dll (a DLL with no code)
1.1 Compile your .RC file using rc.exe. You will get a .res file
1.2 Link you .res in a dll uing link /dll /noentry

2. In the application, load the resources from the external DLL
2.1 Load the dll using LoadLibraryEx with the LOAD_LIBRARY_AS_DATAFILE flag.
    You have to do this before you create the first window or load the first
    string, or image, or whatever.
2.2 Save somewhere the library's HMODULE and use it for any resource
    All API using resources ask for a hInstance. Use the hLibModule.
    If you use MFC, call AfxSetResourceHandle( hLibModule )

A good way to store your localized files is to have a folder for all
languages (MS calls it MUI) and subfolders for each language
(MS uses the LCID as decimal or hex).
There you can put your localized .dll, help, readme, templates, etc.

Example:
<Program Files>
 <Company>
   <Product
     <MUI>
       <409>
         MainApp.dll
         MainApp.chm
         <Templates>
           SomeTemplate.x
           AnotherTemplate.x
           MoreTemplates.x
       <411>
         MainApp.dll
         MainApp.chm
         <Templates>
           SomeTemplate.x
           AnotherTemplate.x
           MoreTemplates.x
       <40C>
         MainApp.dll
         MainApp.chm
         <Templates>
           SomeTemplate.x
           AnotherTemplate.x
           MoreTemplates.x

Important: consider English to be just another language.
This way the code does not need to be different for English,
you can allways use <ApplicationPath>/MUI/<langCode>/... to
access your files.

Signature

Mihai Nita [Microsoft MVP, Windows - SDK]
------------------------------------------
Replace _year_ with _ to get the real email


Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.