zoukankan      html  css  js  c++  java
  • 【MFC】CDialogBar中按钮不可用

    现象展示:

    具体原因:

    A button in a CDialogBar object is disabled automatically if the command routing does not contain a command handler function for the button.
    To enable a button in a CDialogBar object, the command routing must include a command handler for the button. 

    NOTE: Because the CDialogBar object is not included in the routing scheme, the ON_BN_CLICKED() or ON_COMMAND() handler must be placed in one of the objects mentioned above that is in the routing scheme and not in the CDialogBar class.

    解决办法:

    1、如果按钮的消息处理是在CMainFrame中的就不用OnUpdateCmdUI,在其他类的话还是要重载OnUpdateCmdUI的

    2、重载CMainFrame::OnCmdMsg函数

    BOOL CMainFrame::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo)
    {
        if(m_wndDlgBar.OnCmdMsg(nID, nCode, pExtra, pHandlerInfo))
        {
            return TRUE;
        }
        return CMDIFrameWndEx::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo);
    }

    3、重载CDialogBar::OnUpdateCmdUI

    void CMyDialogBar::OnUpdateCmdUI(CFrameWnd* pTarget, BOOL bDisableIfNoHandler)
    {
        CDialogBar::OnUpdateCmdUI(pTarget, FALSE);
    }
  • 相关阅读:
    P2426 删数
    P2115 [USACO14MAR]破坏Sabotage
    P2679 子串
    P2979 [USACO10JAN]奶酪塔Cheese Towers
    P1114 “非常男女”计划
    P2105 K皇后
    P4053 [JSOI2007]建筑抢修
    P1294 高手去散步
    P4316 绿豆蛙的归宿
    P2253 好一个一中腰鼓!
  • 原文地址:https://www.cnblogs.com/yvqvan/p/8574242.html
Copyright © 2011-2022 走看看