Perfect true Color self-painting menu

Source: Internet
Author: User

First, ask questions

On the vckbase, read the implementation of the self-painting menu [Author: querw]. The application of my own ongoing projects found that the effect is good, but there are many problems. There are many defects in the design of the whole class (innate, acquired), the main problems are as follows:

  1. When applied to multiple document interfaces (MDI), it is not possible to customize the system automatically add menus and document template menus (for example, a list of files that cannot be-> the most recent file (MRU) menu items is automatically added to the system). The reason is that there is no function within the class to process the Cmainframe::oninitpopupmenu () message, so it does not have the ability to modify the system to automatically add menu items. (Bcmenu has this function, and the work is good)
  2. The author mentioned that the Bcmenu without mapping Wm_drawitem and Wm_measureitem Two messages can realize the painting function, is actually wrong. Do not map these two important messages, even if you can paint, there is a problem, do not believe that look at the picture.

    Template Menu Sample in the menu editor

    Using Bcmenu and mapping the execution after these two messages

    Using Bcmenu does not map the execution of two messages

    The original author analyzes the top-level because it is incorrect to load the submenu of the main menu (the menu) into a pop-up menu (PopupMenu). The real reason is that the MFC framework automatically invokes the CMenu two virtual functions MeasureItem () and OnDrawItem (). Therefore, when Cmenuex is derived from CMenu, and after the two virtual functions are overridden.

    1. The GetMenu ()->measureitem () of the MFC framework call is equivalent to calling Cmenuex::measureitem (), which enables you to measure the size of a custom menu control.

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.