Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS General Discussion » How to switch language in a SDI application? Collapse All
Subject Author Date
Albert Jams May 31, 2007 - 2:45 AM

Hello:
I’m a newer to Prof-Uis, I’m using Prof-Uis Ver2.70 freeware. It seems the freeware do not supports CExtCustomizeSite, I do something like your LanguageSwitcher, but I failed.
How can I switch language in a SDI application with Prof-Uis Ver2.70 freeware? Can you give me a DEMO?
Please Help me!
Thanks!



Technical Support May 31, 2007 - 9:28 AM

You should switch the preferred language in the resource manager first:

      g_ResourceManager->AllowCustomLang( true );
      g_ResourceManager->SetLangIdDesired( __EXT_MFC_LANG_ID_CHINESE_SIMPLIFIED );
Second, you should re-initialize the command profile in the command manager. It should be recreated and reupdated from all the resources used in your project:
      g_CmdManager->ProfileDestroy( "profile name here", true );
      g_CmdManager->ProfileSetup("profile name here", pMainFrame->m_hWnd );
      g_CmdManager->UpdateFromMenu( "profile name here", . . . );
      g_CmdManager->UpdateFromToolBar( "profile name here", . . . );
That’s all. Finally don’t forget to recomputed the layout of frame windows:
      pMainFrame->RecalcLayout();
      CExtControlBar::stat_RecalcBarMetrics( pMainFrame );
      CExtControlBar::stat_RedrawFloatingFrames( pMainFrame );

Albert Jams May 31, 2007 - 9:21 PM

I Use the AppWizard Create a SDI test application, copy and paste the IDR_MAINFRAME Menu in resource view, change the menu item "View" to "View(CHINESE)" , and change the ID from IDR_MAINFRAME1 to IDR_MAINFRAME.
Then I follow your step and compile the project, but when I switch the language to Chinese, the menubar display nothing, and the submenu item is still English Version. Why?
The Code is as bellow:

void CMainFrame::OnLanguageChinese()
{
BOOL bOn =
        (    g_ResourceManager->IsCustomLangAllowed()
        &&    g_ResourceManager->GetLangIdDesired() == __EXT_MFC_LANG_ID_CHINESE_SIMPLIFIED
        ) ? TRUE : FALSE;
    if( bOn )
        return;

    g_ResourceManager->AllowCustomLang( true );
    g_ResourceManager->SetLangIdDesired( __EXT_MFC_LANG_ID_CHINESE_SIMPLIFIED );

g_CmdManager->ProfileDestroy( __PROF_UIS_PROJECT_CMD_PROFILE_NAME, true );
g_CmdManager->ProfileSetup( __PROF_UIS_PROJECT_CMD_PROFILE_NAME, m_hWnd );
g_CmdManager->UpdateFromMenu( __PROF_UIS_PROJECT_CMD_PROFILE_NAME, IDR_MAINFRAME );
g_CmdManager->UpdateFromToolBar( __PROF_UIS_PROJECT_CMD_PROFILE_NAME, IDR_MAINFRAME );

RecalcLayout();
CExtControlBar::stat_RecalcBarMetrics( this );
CExtControlBar::stat_RedrawFloatingFrames( this );
}

void CMainFrame::OnLanguageEnglish()
{
BOOL bOn =
        (    g_ResourceManager->IsCustomLangAllowed()
        &&    g_ResourceManager->GetLangIdDesired() == __EXT_MFC_LANG_ID_ENGLISH_US
        ) ? TRUE : FALSE;
    if( bOn )
        return;

    g_ResourceManager->AllowCustomLang( true );
    g_ResourceManager->SetLangIdDesired( __EXT_MFC_LANG_ID_ENGLISH_US );

g_CmdManager->ProfileDestroy( __PROF_UIS_PROJECT_CMD_PROFILE_NAME, true );
g_CmdManager->ProfileSetup( __PROF_UIS_PROJECT_CMD_PROFILE_NAME, m_hWnd );
g_CmdManager->UpdateFromMenu( __PROF_UIS_PROJECT_CMD_PROFILE_NAME, IDR_MAINFRAME );
g_CmdManager->UpdateFromToolBar( __PROF_UIS_PROJECT_CMD_PROFILE_NAME, IDR_MAINFRAME );

RecalcLayout();
CExtControlBar::stat_RecalcBarMetrics( this );
CExtControlBar::stat_RedrawFloatingFrames( this );
}

void CMainFrame::OnUpdateLanguageChinese(CCmdUI *pCmdUI)
{
BOOL bOn =
        (    g_ResourceManager->IsCustomLangAllowed()
        &&    g_ResourceManager->GetLangIdDesired() == __EXT_MFC_LANG_ID_CHINESE_SIMPLIFIED
        ) ? TRUE : FALSE;
    pCmdUI->SetCheck( bOn );
}

void CMainFrame::OnUpdateLanguageEnglish(CCmdUI *pCmdUI)
{
BOOL bOn =
        (    g_ResourceManager->IsCustomLangAllowed()
        &&    g_ResourceManager->GetLangIdDesired() == __EXT_MFC_LANG_ID_ENGLISH_US
        ) ? TRUE : FALSE;
    pCmdUI->SetCheck( bOn );
}


Technical Support Jun 2, 2007 - 7:22 AM

If your application is not customizable, the menu bar uses a copy of the window menu which was not recreated in your code. Please reload the menu bar by invoking the CExtMenuControlBar::LoadMenuBar() method.

Albert Jams Jun 3, 2007 - 10:02 PM

I follwed your step, but still failed. I have sent my project’s source code to support@prof-uis.com.

Technical Support Jun 5, 2007 - 11:23 AM

You have two IDR_MAINFRAME menu resources in your project: one is marked as English US and second one is marked as Russian (Russia). But you are going to code support Chinese (PRC) language instead of Russian (Russia). So, please simply change the language of the Russian (Russia) menu to Chinese (PRC) and everything will work fine.