zoukankan      html  css  js  c++  java
  • duilib 时间控件的认识

    CDateTimeUI

    1、该控件继承了CLabelUI控件,该空间并无重写SetAttribute的函数。全部属性跟CLabelUI控件一样。

    2、该控件又有CDateTimeWnd类的一个指针用来显示具体让你选择的时间,该类就是创建的是SysDateTimePick32的控件。

    也许会疑惑,为什么Init函数里面的Create没有关于DateTimePick32的相关说明,但是却能创建出这样一个控件。主要要看CWindowWnd::Create函数,该函数的第一个判断语句在GetSuperClassName()获取到了CDateTimeWnd函数的字符串,因为不为空则调用对应的RegisterSuperclass进行注册DateTimePicker控件。

    这是RegisterSuperClass函数的获取对应DateTimerPicker控件的Wndclassex   ::GetClassInfoEx(NULL, GetSuperClassName(), &wc)

    3、该控件在被选中的时候就New一个CDateTimeWnd的实例,并显示。(见DoEvent)

    4、CDatetimeWnd在失去焦点之后会自动销毁自身,并把时间设置给CDateTimeUI

        LRESULT CDateTimeWnd::OnKillFocus(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
        {
            LRESULT lRes = ::DefWindowProc(m_hWnd, uMsg, wParam, lParam);
            if (m_pOwner->m_nDTUpdateFlag == DT_NONE)
            {
                ::SendMessage(m_hWnd, DTM_GETSYSTEMTIME, 0, (LPARAM)&m_pOwner->m_sysTime);
                m_pOwner->m_nDTUpdateFlag = DT_UPDATE;
                m_pOwner->UpdateText();
            }
            PostMessage(WM_CLOSE);
            return lRes;
        }
    View Code

    该函数最终PostMessage(WM_CLOSE); 

    然后该函数就会调用OnFinalMessage

    void CDateTimeWnd::OnFinalMessage(HWND /*hWnd*/)
        {
            // Clear reference and die
            if( m_hBkBrush != NULL ) ::DeleteObject(m_hBkBrush);
            m_pOwner->m_pWindow = NULL;
            delete this;
        }
    View Code

    进行资源的释放。

    对应的在__ControlProc函数,该函数在注册RegisterSuperclass的时候设置的回掉函数。

    如果是普通的创建则在对应的回掉__WndProc函数。

    同理:CEduiUI控件也做了跟时间空间类似的处理方式,只是在CEditUI类中多添加了相应的设置属性等函数。

  • 相关阅读:
    How to function call using 'this' inside forEach loop
    jquery.validate.unobtrusive not working with dynamic injected elements
    Difference between jQuery.extend and jQuery.fn.extend?
    Methods, Computed, and Watchers in Vue.js
    Caution using watchers for objects in Vue
    How to Watch Deep Data Structures in Vue (Arrays and Objects)
    Page: DOMContentLoaded, load, beforeunload, unload
    linux bridge
    linux bridge
    EVE-NG网卡桥接
  • 原文地址:https://www.cnblogs.com/cxiaoln/p/4379372.html
Copyright © 2011-2022 走看看