我按着网上的文章做的。派生了CDialogBar类,自定义了Create函数
BOOL CMyDialogBar::Create(CWnd *pParentWnd, UINT nIDTemplate, UINT nStyle, UINT nID)
{
// TODO: Add your specialized code here and/or call the base class
BOOL bRes=CDialogBar::Create(pParentWnd,nIDTemplate,nStyle,nID );
InitDialogBar();//在类中添加一个成员函数就可以了
return bRes;}//定义
BOOL CMyDialogBar::InitDialogBar()
{
UpdateData(FALSE);//
return TRUE;
}//在框架类Create函数中创建
 if(!m_dialogbar.Create(this,IDD_DIALOG1,CBRS_RIGHT|CBRS_GRIPPER,IDD_DIALOG1))
 {
 TRACE0("Failed to create dialogbar\n");
  return -1;
 } m_dialogbar.SetWindowText("对话框工具栏");
我在对话框面板上添加了一个按钮,但显示是灰色的。
为什么?
我已经更新了界面了?

解决方案 »

  1.   

    http://support.microsoft.com/default.aspx?scid=kb;en-us;98198
      

  2.   

    在主函数中添加OnCmdMsg这个虚函数就可以了,具体写法如下:
    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_dialogbar.OnCmdMsg(nID,nCode,pExtra,pHandlerInfo)){
    return TRUE;
    } return CFrameWnd::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo);
    }这样就可以了
      

  3.   

    因为没有命令处理函数,所以会这样,用enddialog返回按钮的标示,然后添加处理就可以了.
      

  4.   

    BEGIN_MESSAGE_MAP(CLeftDlgBar, CDialogBar)
    ON_UPDATE_COMMAND_UI(IDC_BUTTON1,OnUpdateButton1)
    END_MESSAGE_MAP()
    void CLeftDlgBar::OnUpdateButton1(CCmdUI* pCmdUI)
    {
    pCmdUI->Enable(TRUE); //using pCmdUI->SetText you can set the button text too
    }
      

  5.   

    must process OnUpdateCmdUI message.
    add your handler code there.
      

  6.   

    楼上:mengqimxz的回复是正确的,消息需要转发给dialogbar处理,我就是这样做的。 回复人:mengqimxz(*雨*) ( 三级(初级)) 信誉:100  2005-03-22 10:40:00  得分:0

    在主函数中添加OnCmdMsg这个虚函数就可以了,具体写法如下:
    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_dialogbar.OnCmdMsg(nID,nCode,pExtra,pHandlerInfo)){
    return TRUE;
    }return CFrameWnd::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo);
    }