Message pumps and virtual windows in the Duilib

Source: Internet
Author: User

message pumps and virtual windows in the Duilib


I. Structure of the message pump

The Cnotifypump class is the root parent class that constructs the DUILIB message pump, and the window class to use the message pump mechanism should inherit from that class. On the basis of the inheritance relationship, through Dui_declare_message_map, Dui_begin_message_map, Dui_end_message_map, Dui_on_msgtype, DUI_ON_MSGTYPE_ Ctrname, Dui_on_click_ctrname, Dui_on_selectchanged_ctrname, Dui_on_killfocus_ctrname, DUI_ON_MENU_CTRNAME, DUI_ON_ Timer and other macros construct the link list structure of the message pump and the correspondence between event and processing function. The specific implementation method refers to the MFC message mechanism.



second, the message pump processing process

The OnCreate function of Windowimplbase, by default, adds itself to the Notifier,windowimplbase object of the Cpaintmanagerui notify message equivalent to a listener of the event message, and when an event occurs, The Windowimplbase notify function is called, and the Notify function calls Cnotifypump::notifypump into the message pump. After entering the message pump, first check whether there is a virtual window in the current window class to handle the event, if not, find out if the current window class has a function to handle it, if not, go to the parent class for similar lookups until the Cnotifypump class.


third, the use of virtual Windows

CNOTIFYPUMP::M_VIRTUALWNDMAP provides management capabilities for virtual Windows. The so-called virtual window, is a fake window, do not need to inherit from the Cwindowwnd class, in fact, duilib with a string to indicate (represent) a virtual window. Using a virtual window, you can intercept messages sent to the corresponding real window in the message pump for processing, and the real window cannot capture the message. The following steps are used:

1. Generate a virtual window class from Cnotifypump inheritance, assuming Cmyvirtualwnd

2, after instantiating a real window class, instantiate a Cmyvirtualwnd class object, and add the virtual window object that was previously instantiated through the addvirtualwnd of the real window class, assuming Addvirtualwnd specifies that the virtual window object corresponds to the name Vwnd

3. The Svirtualwnd assignment of the event that will be handed over to the virtual window object is Vwnd

4, using Dui_on_msgtype and other macros, in the Cmyvirtualwnd to define the event corresponding to the processing function


The sample code is shown in the attachment.

This article from the "It Technology sharing" blog, reproduced please contact the author!

Message pumps and virtual windows in the Duilib

Related Article

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.