The delivery of Window message processing objects in Python

Source: Internet
Author: User
Tags in python

In the previous definition of the window of the message processing class, although has the processing power, but has not been put into the callback function to make the corresponding call, it is still not up to the target, but also need the following two details of processing, can be embedded in the message processing process. We will follow the message class delivery path to analyze its specific process, so that the understanding of a more smooth, more ordinary thinking. The specific process is shown in the following illustration:

As you can see from the figure above, you use the Controller class to create the instance object Ctrl of the window processing message, and then pass it to the instance object of Winmaker, which is the function created that is passed to the Create window, the message that passes through the creation window of the operating system wm_ Nccreate brings the callback function Pywndproc, in response to the message wm_nccreate in the Pywndproc function, takes out the Controller class object and binds it to the corresponding window. This step is implemented through the WIN32 API function Setwindowlongw. All future messages in the window will be based on the handle of the window to get the message processing object bound to the window processing, and the object to get the window message handler class is obtained by the function Getwindowlongw. This allows you to handle the message that your window needs to handle by using a window message to process the function Mywndproc of the class. As you can see here, the callback function Pywndproc is provided to all windows for message processing, but it gets the message processing object of the window according to the window handle to handle the messages for each window. After this design, you can implement different Windows using different classes to process messages, the corresponding events to limit the scope of a window, so that the processing window message code clearer, better maintenance.

Back to the column page: http://www.bianceng.cnhttp://www.bianceng.cn/Programming/extra/

Author: csdn Blog Caimouse

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.