WM_DRAWITEM是一般的消息,如果一个按钮设置了自绘,那么他会给父窗口发送WM_DRAWITEM,父窗口找到消息处理函数
看源码:
void CWnd::OnDrawItem(int /*nIDCtl*/, LPDRAWITEMSTRUCT lpDrawItemStruct)
{
if (lpDrawItemStruct->CtlType == ODT_MENU)
{
CMenu* pMenu = CMenu::FromHandlePermanent(
(HMENU)lpDrawItemStruct->hwndItem);
if (pMenu != NULL)
{
pMenu->DrawItem(lpDrawItemStruct);
return; // eat it
}
}
else
{
// reflect notification to child window control
if (ReflectLastMsg(lpDrawItemStruct->hwndItem))
return; // eat it
}
// not handled - do default
Default();
}
如果发送给父窗口的控件是菜单的话就执行if里面的代码,如果不是的话就将消息反射给控件ReflectLastMsg(lpDrawItemStruct->hwndItem)