?
Solved

How to automatically load differernt language names of satellite dll files which are built for different language resource files into a drop-down box of a dialog?

Posted on 2005-03-07
7
Medium Priority
?
782 Views
Last Modified: 2013-11-20
How to automatically load differernt language names of satellite dll files which are built for different language resource files into a drop-down box of a dialog? And how to dynamically load the corresponding language resource file in according to the language selection?

 
0
Comment
Question by:yangfang_mun
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
7 Comments
 
LVL 16

Expert Comment

by:nonubik
ID: 13484327
You place all the dll in a folder. Then use CFileFind to browse through all the dlls.
At runtime you load the selected library.

CFileFind      PluginFinder;
CString      strPath = _T("c:\\language dll folder"); //fill it

strPath += _T("\\*.dll");

BOOL      bFind = PluginFinder.FindFile(strPath);

while(bFind)
{
      bFind = PluginFinder.FindNextFile();
                m_Combo.AddString(PluginFinder.GetFilePath());
}      

PluginFinder.Close();

//now you have all the dll names in the combo.

>And how to dynamically load the corresponding language resource file in according to the language selection?

CString strDllName;
m_Combo.GetLBText(m_Combo.GetCurSel(), strDllName);
HINSTANCE   hDll = LoadLibrary(strDllName);

//...later
if(hDll)
   FreeLibrary(hDll);
0
 
LVL 2

Expert Comment

by:berberski
ID: 13484412
An little addition to nonubik comment. You can use the following line
AfxGetModuleState()->m_appLangDLL = hDll;
to change language dll for the entire application. With this all of your MFC's LoadString will work.
0
 

Author Comment

by:yangfang_mun
ID: 13486788
Thanks for your code. That's really helpful.

When I added in "AfxGetModuleState()->m_appLangDLL = hDll;" and compiled it, I got the following error:
E:\Working\ANTARES 2.7\ConfigLangDlg.cpp(63) : error C2039: 'm_appLangDLL' : is not a member of 'AFX_MODULE_STATE'

It seems really strange and I went to AFXSTAT_.H to check, I can see the following:
class AFX_MODULE_STATE : public CNoTrackObject

And in this class, it defines m_appLangDll as following:
ifdef _AFXDLL
      // CDynLinkLibrary objects (for resource chain)
      CTypedSimpleList<CDynLinkLibrary*> m_libraryList;

      // special case for MFCxxLOC.DLL (localized MFC resources)
      HINSTANCE m_appLangDLL;
#endif

Do you have any idea about this problem?
Thanks a lot.
0
Get proactive database performance tuning online

At Percona’s web store you can order full Percona Database Performance Audit in minutes. Find out the health of your database, and how to improve it. Pay online with a credit card. Improve your database performance now!

 
LVL 16

Expert Comment

by:nonubik
ID: 13487085
>Do you have any idea about this problem?

Seems you do not have defined the _AFXDLL macro.
0
 
LVL 2

Expert Comment

by:berberski
ID: 13487365
This macro is defined in MFC Extension library only:(
You can create your own extension dll in which you can use m_appLangDll. For a big application this can be useful.
0
 

Author Comment

by:yangfang_mun
ID: 13489869
Sorry I am newer for MFC.

Now I already insert language in my language dialog combo box which is in the configuration of File Menu. And ConfigLangDlg.cpp and ConfigLangDlg.h are added in. I am adding the following piece of code in ConfigLangDlg.cpp.
      
                CString strLang = theApp.GetProfileString("Language", "Selected", "English");
      m_ctrlLangCombo.SetCurSel(m_ctrlLangCombo.FindString(-1, strLang));
      m_ctrlLangCombo.GetLBText(m_ctrlLangCombo.GetCurSel(), strLang);
      strLang +=_T("\\.dll");
      HINSTANCE hDll = LoadLibrary(strLang);

I wish I can modify the setting of language which is in configuration and it can show me the corresponding menu in that language. But it seems not work. Any suggestion? Is it necessary to have to create my own extension dll?

Thanks.
0
 
LVL 2

Accepted Solution

by:
berberski earned 2000 total points
ID: 13490691
Dear yannqfanq_mun
Please visit http://www.codeproject.com/cpp/mult_lang_support.asp. May be it is the right example for you.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question