MFC Programmer WTL Guide (6) Advanced dialog user interface class

Source: Internet
Author: User

The fifth chapter introduces

In the previous article we introduced some of the WTL features associated with dialog boxes and controls, which are the same as MFC's corresponding classes. This article introduces new classes that implement advanced interface features: control self-painting and custom skin controls, new WTL controls, UI updating, and dialog data validation (DDV).

Special custom drawing and Appearance custom class

Since painting and customizing the appearance controls are a common tool in the graphical user interface, WTL provides several embedded classes to do the tedious work. I will then introduce them, in fact we have done so at the end of the previous example project CONTROLMANIA2. If you're following my lead. Using the Application Generation Wizard to create a new project, don't forget to use the modeless dialog box, and I'll explain in detail why this is done in the UI updating section of the Control in the dialog box, so that you have to use the modeless dialog box for normal work.

Cownerdraw

The control's own painting needs to respond to four messages: Wm_measureitem, Wm_drawitem, Wm_compareitem, and Wm_deleteitem, The Cownerdraw class defined in the Atlframe.h header simplifies these tasks, and you don't need to deal with the four messages using this class, you just link the message to the Cownerdraw and it calls the overloaded functions in your class.

How to link messages to Cownerdraw depends on whether or not you reflect the message to the control, the two methods are somewhat different. The following is a chain of message mappings for the Cownerdraw class, which makes the differences between the two methods more pronounced:

template <class T> class COwnerDraw
{
public:
  BEGIN_MSG_MAP(COwnerDraw<T>)
   MESSAGE_HANDLER(WM_DRAWITEM, OnDrawItem)
   MESSAGE_HANDLER(WM_MEASUREITEM, OnMeasureItem)
   MESSAGE_HANDLER(WM_COMPAREITEM, OnCompareItem)
   MESSAGE_HANDLER(WM_DELETEITEM, OnDeleteItem)
  ALT_MSG_MAP(1)
   MESSAGE_HANDLER(OCM_DRAWITEM, OnDrawItem)
   MESSAGE_HANDLER(OCM_MEASUREITEM, OnMeasureItem)
   MESSAGE_HANDLER(OCM_COMPAREITEM, OnCompareItem)
   MESSAGE_HANDLER(OCM_DELETEITEM, OnDeleteItem)
  END_MSG_MAP()
};

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.