zoukankan      html  css  js  c++  java
  • DUILIB消息处理过程

    DUILIB消息处理机制

    方法一、

    首先窗口基类创建 CWindowWnd->Create()

    调用 CWindowWnd->RegisterWindowClass() 注册 CWindowWnd->__WndProc() 为本界面窗口消息处理函数

     __WndProc()调用 虚函数 CWindowWnd->HandleMessage() 处理消息

    WinImplBase继承 CWindowWnd 并重写了 HandleMessage()处理消息 该函数拦截 WM_CREATE 、WM_MOUSEMOVE等常见消息,并转发至 该类对应的虚函数 WinImplBase::OnCreate(),WinImplBase::OnMouseMove()等 ,

    之后WinImplBase::HandleMessage()函数调用 该类虚方法 WinImplBase::HandleCustomMessage()

    此时我们可以自己重写窗口的 HandleCustomMessage(),OnCreate(), OnMouseMove()等 方法进行消息过程处理

    最后WinImplBase::HandleMessage()函数调用该类的成员CPaintManagerUI  m_pm的MessageHandler()方法;

     在m_pm的MessageHandler()方法中首先调用了LRESULT lResult = static_cast<IMessageFilterUI*>(m_aMessageFilters[i])->MessageHandler(uMsg, wParam, lParam, bHandled);

     此时我们可以实现 IMessageFilterUI接口并调用CPaintManagerUI::AddPreMessageFilter()  添加到m_aMessageFilters过滤队列中,在IMessageFilterUI::MessageHandler(uMsg, wParam, lParam, bHandled);中处理消息

     之后调用了 static_cast<INotifyUI*>(m_aNotifiers[j])->Notify(*pMsg);

    此时我们可以实现INotifyUI,调用CPaintManagerUI::AddNotifier,将自身加入Notifier队列。

    方法 二、

    CPaintManagerUI::MessageLoop() 消息泵  调用 CPaintManagerUI::TranslateMessage(const LPMSG pMsg)来进行分发消息

    该函数会调用 该类 PreMessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT& /*lRes*/)

    之后在PreMessageHandler() 中调用 LRESULT lResult = static_cast<IMessageFilterUI*>(m_aPreMessageFilters[i])->MessageHandler(uMsg, wParam, lParam, bHandled);

    此时我们可以实现IMessageFilterUI接口并调用CPaintManagerUI::AddPreMessageFilter()  过滤队列中,通过此方法可以 在窗口处理之前 先对消息进行预处理

  • 相关阅读:
    Channel使用技巧
    Flask开发技巧之异常处理
    后端开发使用pycharm的技巧
    python单元测试
    Docker入门介绍
    python高阶函数的使用
    python内置模块collections介绍
    python中@property装饰器的使用
    三次握手四次挥手
    python类方法@classmethod与@staticmethod
  • 原文地址:https://www.cnblogs.com/guozht/p/10132999.html
Copyright © 2011-2022 走看看