问题是这样的:定义一个新的类继承CHotKeyCtrl
,我想更改热键中的文本颜色。使用ON_WM_CTLCOLOR_REFLECT
,但测试颜色未更改。onctlcolor
函数无法运行。
MyHotKey.h
class CMyHotKey: public CHotKeyCtrl
{
DECLARE_DYNAMIC(CMyHotKey)
protected:
DECLARE_MESSAGE_MAP()
public:
afx_msg HBRUSH CtlColor(CDC* pDC, UINT nCtlColor);
};
MyHotKey.cpp
BEGIN_MESSAGE_MAP(CMyHotkey, CHotKeyCtrl)
ON_WM_CTLCOLOR_REFLECT()
ON_WM_ERASEBKGND()
END_MESSAGE_MAP()
HBRUSH CMyHotKey::CtlColor(CDC* pDC, UINT nCtlColor)
{
if(pDC)
{
pDC->SetTextColor(RGB(255,0,0));
pDC->SetBkMode(TRANSPARENT);
}
return (HBRUSH)GetStockObject(NULL_BRUSH);
}
任何人都可以提出我可能做错的建议吗?