如何让MFC的组合框标题改变颜色,不是想改变所有字体的颜色,只是改变组合框标题的颜色。
1个回答
展开全部
如果是在其父窗口中处理,那么响应WM_CTLCOLOR消息,并在nCtlColor == CTLCOLOR_EDIT时对pDC进行SetTextColor即可。
如果在控件本身(subclass)处理,那么响应反射的WM_CTLCOLOR消息(OCM__BASE+WM_CTLCOLOR)
如果在控件本身(subclass)处理,那么响应反射的WM_CTLCOLOR消息(OCM__BASE+WM_CTLCOLOR)
追问
(OCM__BASE+WM_CTLCOLOR) 具体怎么写??
追答
上面写错了,OCM__BASE应该是WM_REFLECT_BASE
头文件:
afx_msg HBRUSH CtlColor(CDC* pDC, UINT nCtlColor);
实现:
BEGIN_MESSAGE_MAP(CMyCombo, CComboBox)
//{{AFX_MSG_MAP(CMyCombo)
ON_WM_CTLCOLOR_REFLECT()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
HBRUSH CMyCombo::CtlColor(CDC* pDC, UINT nCtlColor)
{
// TODO: Change any attributes of the DC here
// TODO: Return a non-NULL brush if the parent's handler should not be called
pDC->SetTextColor(RGB(255,0,0));
}
/*
#define ON_WM_CTLCOLOR_REFLECT() \
{ WM_CTLCOLOR+WM_REFLECT_BASE, 0, 0, 0, AfxSig_hDw, \
(AFX_PMSG)(AFX_PMSGW)(HBRUSH (AFX_MSG_CALL CWnd::*)(CDC*, UINT))CtlColor },
*/
另外,可以看看CWnd::ReflectChildNotify
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询