自己从CDialogBar继承了一个类,
class CWMDialogBar : public CDialogBar1。要怎样才能在CWMDialogBar中自己处理对话框中控件的消息呢?
2。还有一个问题是,怎样才能改变该DialogBar关联的对话框的背景色呢?
我的代码如下
void CWMDialogBar::OnPaint() 
{
CPaintDC dc(this); // device context for painting

// TODO: Add your message handler code here
dc.SetBkColor(RGB(255,0,0));

// Do not call CDialogBar::OnPaint() for painting messages
}
但是却没有效果。谢谢了

解决方案 »

  1.   

    1.sendmessage不行吗?
    2.不能这样吧,,,是不是得由对话框改变吧
      

  2.   

    hit255() :
    不知道您说的sendmessage,是写在哪里
    我就是希望减少CWMDialogBar  和其他类(如CFrameWnd,CView)之间的耦合性,
    所有的消息都在CWMDialogBar  里面处理。不知道有没有什么好办法谢谢了
      

  3.   

    dialogbar上一般不是直接放控件的,
    而是放dialog的The CDialogBar class provides the functionality of a Windows modeless dialog box in a control bar. A dialog bar resembles a dialog box in that it contains standard Windows controls that the user can tab between. Another similarity is that you create a dialog template to represent the dialog bar.
      

  4.   

    2,改变颜色,可以自己用DC用FillRect函数来把背景色从绘
    int FillRect(
      HDC hDC,           // handle to DC
      CONST RECT *lprc,  // rectangle
      HBRUSH hbr         // handle to brush
    );
      

  5.   

    谢谢各位
    特别谢谢jinxing1(金星) 
    背景色的问题已经解决了现在就剩消息处理的问题了,因为在程序中要用的多个dialogbar,所以如果全都在主框架中处理,会很乱。
    我还是希望能在自己的CWMDialogBar 类中自己处理。
    不知道有没有什么好办法
      

  6.   

    对话框中的控件 和 你的CWMDialogBar啥关系啊?
    为啥后者能处理前者的消息?(什么消息,控件发出的?还是给控件的?)
      

  7.   

    加了按钮响应事件,不过这样的话,按钮还是不可用的,
    在BOOL CMainFrame::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo) 
    {
    // TODO: Add your specialized code here and/or call the base class
    if (m_wndColor.OnCmdMsg(nID,nCode,pExtra,pHandlerInfo))
    return TRUE;
    return CFrameWnd::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo);
    }m_wndColor为CWMDialogBar的对象`~~~这样就可以了`~~一般的事件都可以写在自己的的CWMDialogBar里`~