Implement multi-language programming interface in the mfc sdi Program

Source: Internet
Author: User

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:

    1. Add language. h/CPP to the project and # include "stdafx. H" in CPP ".
    2. Define a global variable g_hinst and assign it to the resource module handle (usually theapp. m_hinstance) in initinstance ).
    3. In initinstance (), call clanguage: Initialize () to determine the language to be used.
    4. In cmainframe: oncreate (), call clanguage: translatemenu () to translate the main menu.
    5. Reload cframewnd: getmenustring () and use clanguage: translatestring () to replace its afxloadstring () to load the resource string.
    6. The clanguage: translatedialog () Translation dialog box is called in oninitdialog () of each dialog box.
    7. 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......

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.