Re: multiple language support: dialog-boxes
"Mihai N." <nmihai_year_2000@yahoo.com> wrote in message
news:Xns9D9D15F01DF9DMihaiN@207.46.248.16...
I`ve a sdi application where I want to add multiple language support.
If the user press the button btn1, the language should be changed.
For anything beyond a trivial application, you should just give up.
Once you change the current resource dll, to update everything you
would really have to destroy all existing menus and dialogs and
re-load them from the new dll, refresh all views, update all titles,
etc.
The use cases where an "on they fly" update is justified are realy low.
I would recomend to do what most applications do: once the user changes
the language, save the setting somewhere, show a message saying
"the change will take effect the next time you start the application"
and call it a day.
At the next application start read the saved setting very-very early
in the startup process and load the resource dll.
With the *old* menu structure generated by the AppWizard, it isn't hard to
do it on the fly. Just load the new menu from the DLL for Document present
(hMenuDoc) and no Document present, (hMenuNoDoc) and then:
// Update the document menu, which is held as a static member
// of CMyDoc:
HMENU hMenuDocOld = CMyDoc::mdDefaultMenuSet( hMenuDoc );
// Update the non-document menu, which is held as
// m_hMenuDefault in the frame window:
HMENU hMenuNoDocOld = pFrameWnd->m_hMenuDefault; // the current
default.
pFrameWnd->m_hMenuDefault = hMenuNoDoc;
pFrameWnd->OnUpdateFrameMenu( NULL );
pFrameWnd->DrawMenuBar();
// Tidy up old menus:
if( hMenuDocOld ) ::DestroyMenu( hMenuDocOld );
if( hMenuNoDocOld ) ::DestroyMenu( hMenuNoDocOld );
with:
HMENU CMyDoc::mdDefaultMenuSet( HMENU hMenuDoc )
{
HMENU hMenuOld = m_hMenuMzDocument;
m_hMenuMzDocument = hMenuDoc;
return hMenuOld;
}
Caveat: I have yet to find out whether this works with fancy new
CMFCMenuBar, but I intend to explore it before too long.
Dave
--
David Webber
Mozart Music Software
http://www.mozart.co.uk
For discussion and support see
http://www.mozart.co.uk/mozartists/mailinglist.htm