Download: sdiml (34 K, Visual C ++ 6 Project)
Let's give an example today to illustrate how to use the clanguage class.Program.
Because MFC encapsulates some string display processing, it may be a little different from Win32 engineering. There are two main points:
- Because the menu items in the language list are dynamically generated, the MFC mechanism makes these menu items unavailable. Therefore, you must make the language list menu item available when updating the command UI.
- The menu prompt is implemented by cframewnd. We must reload its getmenustring () and replace its afxloadstring () with the clanguage's translatestring () to load the resource string.
The following is a brief step:
- Add language. h/CPP to the project and # include "stdafx. H" in CPP ".
- Define a global variable g_hinst and assign it to the resource module handle (usually theapp. m_hinstance) in initinstance ).
- In initinstance (), call clanguage: Initialize () to determine the language to be used.
- In cmainframe: oncreate (), call clanguage: translatemenu () to translate the main menu.
- Reload cframewnd: getmenustring () and use clanguage: translatestring () to replace its afxloadstring () to load the resource string.
- The clanguage: translatedialog () Translation dialog box is called in oninitdialog () of each dialog box.
- Other projects are the same as Win32 projects ......
In addition, it may be slightly different if it is used in MDI, becauseArticleThe position of the popup menu cannot be changed. Therefore, each time you change the language, do not maximize all the MDI sub-Windows (because a menu icon is added to the main menu to change the position of popup )......
ViewCode......