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 » When I switch language, the MenuBar display nothing. Why? Collapse All
Subject Author Date
Albert Jams Jun 1, 2007 - 9:01 AM

I Use the AppWizard Create a SDI application, copy and paste the IDR_MAINFRAME Menu in resource view, change the menu item "View" to "View(CHINESE)" , change the resource language from English to Chinese, and change the ID from IDR_MAINFRAME1 to IDR_MAINFRAME.
Then I follow your step in the article "Re:How to switch language in a SDI application?", 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?
Please help me !
Thanks!

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:01 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.

Suhai Gyorgy Jun 1, 2007 - 9:21 AM

First comment as a programmer: your methods OnLanguageEnglish and OnLanguageChinese has the same exact code except for the language ID, so you should make only one method with that code. This new method could have a parameter for the language ID you would like to switch to. And then from OnLanguageEnglish and OnLanguageChinese you’d just call this one method with the appropiate ID.

As for your question: I think you need to call m_wndMenuBar->UpdateMenuBar() before RecalcLayout();. (I guess you have a CExtMenuControlBar m_wndMenuBar variable in your MainFrame class)