dcsimg

On-The-Fly UI (User Interface) Language Changing

WEBINAR:
On-Demand

Desktop-as-a-Service Designed for Any Cloud ? Nutanix Frame


Environment: VC++.NET on Windows XP

Dear Reader,

Hello! Many people have sent me messages asking about how to make language DLL's and so on and so forth. But, if you are looking for a quick and easy solution, why not give this a whirl? This is just one example of how to change the interface's language on-the-fly. There are many, many ways to do this, so don't think I'm giving a "this is the only way to do it" tutorial. I just want to broaden your mind.

The "insane" demo includes some other interesting things, such as how to change your menus, tooltips, statusbar text, and so forth dynamically at runtime. I think that I've gotten most of the bugs worked out of it. Anyway, here it goes! It's gonna be a rocky ride, but just bear with me! Hope you can follow!

From, Omoshima

P.S. THIS IS ONLY AN EXAMPLE, TAKE THIS AND RUN WITH IT!!!
P.P.S. BTW, I'll soon be uploading a tutorial based around DLLs.

Vague, Hard-To-Follow Instructions (hopefully not!!)

  1. First and foremost, you must add the "LangIni.h" and "LangIni.cpp" files to the project.
  2. Then, add a variable to your C****App class.
  3. In your C****Dlg::OnInitDialog() function, call (or not) a function to set up all the buttons/texts in your dialog. I called mine "InitControls".
  4. void C****Dlg::InitControls(void)
    {
        SetDlgItemText(IDOK, 
                       theApp.m_langINI.GetValue("Button",
                       "OK"));
        SetDlgItemText(IDCANCEL,
                       theApp.m_langINI.GetValue("Button",
                                                 "Cancel"));
        SetDlgItemText(IDC_PROMPT,
                       theApp.m_langINI.GetValue("Prompt",
                                                 "Prompt"));
        SetDlgItemText(IDC_PROMPT_ENGLISH, 
                       theApp.m_langINI.GetValue("Prompt",
                                                 "Lang1"));
        SetDlgItemText(IDC_PROMPT_JAPANESE,
                       theApp.m_langINI.GetValue("Prompt",
                                                 "Lang2"));
      }
    
  5. Then, add handlers for ON_BN_CLICKED for the radio buttons.
  6. void CUILangDlg::OnBnClickedPromptEnglish()
    {
    // TODO: Add your control notification handler
    // code here
    theApp.m_langINI.LoadFile("english.ini");
    InitControls();
    }
    
    void CUILangDlg::OnBnClickedPromptJapanese()
    {
    // TODO: Add your control notification handler 
    //code here
    theApp.m_langINI.LoadFile("japanese.ini");
    InitControls();
    }
    

Downloads

Download the easy demo's source - 20.5 KB (21,029 bytes)
Download easy demo - 174 KB (178,778 bytes)

Download the insane demo's source - 34.9 KB (35,779 bytes)
Download insane demo - 205 KB (210,689 bytes)


Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date