关于自绘

WM_DRAWITEM 在WTL中对应COwnerDraw,属普通Message
    The WM_DRAWITEM message is sent to the parent window of an owner-drawn button, combo box, list box, or menu when a visual aspect of the button, combo box, list box, or menu has changed.

也就是说WM_DRAWITEM这套消息支持如下控件:
button, combo box, list box, or menu

NM_CUSTOMDRAW 在WTL中对应CCustomDraw,属ON_NOTIFY消息

lpNMCustomDraw
Pointer to a custom draw-related structure that contains information about the drawing operation. The following list specifies the controls and their associated structures.
List view
NMLVCUSTOMDRAW
ToolTip
NMTTCUSTOMDRAW
Tree view
NMTVCUSTOMDRAW
Toolbar
NMTBCUSTOMDRAW
All other supported controls
NMCUSTOMDRAW

Currently, the following controls support custom draw functionality: header, list view, rebar, toolbar, ToolTip, trackbar, and tree view. Custom draw is also supported for button controls if you are running Windows XP and have an application manifest to ensure that Comctl32.dll version 6 is available.

而NM_CUSTOMDRAW消息支持几个扩展控件。

自绘CHeaderCtrl
    CHeaderCtrl也会发NM_CUSTOMDRAW 消息,CHeaderCtrl控件本身的高度是可以通过设置字体或ImageList来调整的,但整合进CListView中的HeaderCtrl就不行了,要改变此HeaderCtrl的高度,需要响应HDM_LAYOUT消息,在此消息中设置。如:
LRESULT OnLayOut(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
    {
        LPHDLAYOUT pLayout = (LPHDLAYOUT)lParam;
        pLayout->pwpos->hwnd            = m_hWnd;
        pLayout->pwpos->hwndInsertAfter = NULL;
        pLayout->pwpos->flags            = SWP_FRAMECHANGED;

        pLayout->pwpos->x                = pLayout->prc->left;
        pLayout->pwpos->y                = 0;
        pLayout->pwpos->cx                = pLayout->prc->right - pLayout->prc->left;
        pLayout->pwpos->cy                = m_nHeight;
        pLayout->prc->top                = m_nHeight;
        return 1L;
    };


 


 

 

你可能感兴趣的:(关于自绘)