主要代码如下:在MainFrame 中:CDialogBar m_wndLeftDialogBar;
if (!m_wndLeftDialogBar.Create(this, CG_IDD_LEFTDIALOGBAR,
CBRS_LEFT | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_HIDE_INPLACE,
CG_ID_VIEW_LEFTDIALOGBAR))
{
TRACE0("Failed to create dialog bar m_wndLeftDialogBar\n");
return -1; // fail to create
}
在   m_wndLeftDialogBar所在的cpp 代码中我定义了
  HBRUSH CMyDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) 
    {
       HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
  
       // TODO: Change any attributes of the DC here
       return m_brush;
       // TODO: Return a different brush if the default is not desired
       //return hbr;
    }问题是MainFrame不响应这个函数 我设置了断点~这个函数根本就没有用到~这样我改变不了这个CDialogBar 的颜色 请问应该怎么样才能让MainFrame 响应这个函数

解决方案 »

  1.   

    不知道你的dialogbar是否派生正确HBRUSH CMyDialogBar::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
    {
    HBRUSH hbr = CDialogBar::OnCtlColor(pDC, pWnd, nCtlColor);
             。。
    }
      

  2.   

    派生一个dialogbarBOOL CMyDialogBar::OnEraseBkgnd(CDC* pDC) 
    {
        CBrush brush(RGB(255,0,0));
        CRect rectClient;
        GetClientRect(rectClient);    pDC->FillRect(rectClient, &brush);    return TRUE;
    }
      

  3.   

    http://dev.csdn.net/develop/article/49/article/48/48052.shtm
      

  4.   

    你可以派生static,edit或者button,在派生类里改变caption得颜色..在派生类里改变控件颜色相信你会..不会得话网上也有很多现成的派生类http://www.codeguru.com/Cpp/controls/staticctrl/article.php/c2927/如此就和在对话框中一样的处理了