1

问题是这样的:定义一个新的类继承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);
}

谁能建议我可能做错了什么?

4

0 回答 0