Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
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
?
790 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
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Question has a verified solution.

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

Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses

572 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