在多文档工程里面,新建了一个CDialogBar,上面放个按钮,标题设为:Button(&B),现在按钮的快捷键没办法响应,求高人指点,怎么操作才能让CDialogBar上的按钮能够响应快捷键?
本人比较愚笨,回答最好能具体点,谢谢,另外,我没几分了……

解决方案 »

  1.   

    不会吧,我按 Alt+B 时没有任何反应。
      

  2.   

    难道我的过程有错?
    你是怎么弄的,说一下吧,CDialogBar和按钮都是怎么弄的,谢谢。
    今天我是头一次弄这个CDialogBar。
      

  3.   

    ResourceView下选择Dialog右键,再选择Insert...,再选Dialog,再选NEW把你的按钮放上去,右键,选Properties,把Caption改成Button(&B)再双击这个按钮,选Create a new class,取个名字,我取的是MyDialog,然后OK,然后"是",再OK找到你要调用这个DIALOG的地方.导入刚才生成的头文件.我导的是#include "MyDialog.h",然后在你要调用的地方加代码MyDialog DlgMyDilog;,然后再DlgMyDialog.DoModal();运行程序试试吧感觉我像在教学生
      

  4.   

    不明白,我是这样做的,
    在MainFrm.h中添加:
        CDialogBar   m_bar1;
        afx_msg void OnDialogBarButton();  在MainFrm.cpp添加下面代码
    BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd)
        ON_COMMAND(IDC_BTN,OnDialogBarButton)
    END_MESSAGE_MAP()OnCreate()函数中:
    if(!m_bar1.Create(this,IDD_DIALOGBAR,WS_VISIBLE | CBRS_TOP,IDD_DIALOGBAR))  
        {   
            AfxMessageBox("error!");   
            return -1;   
        } 
    再添加Button对应函数:
    void   CMainFrame::OnDialogBarButton()   
    {   
        MessageBox("Button down.");   
    }这样出来以后,单击CDialogBar上的Button,可以正常响应,弹出MessageBox,但是按Alt+B,就什么反应都没有了。
    应该怎么做,请指教。
    另外,你说的双击按钮新建一个类,这个是什么作用,我不太明白
    /////////////////////////////////////////////////////////
    题外话,赚我这个笨人这点分不怎么容易,辛苦了,问题解决后一定给分。
      

  5.   

    晕...我也一直弄错了...不好意思...我以为你要加的是个普通的DIALOG下面给你方法:
    step1:   
      在资源编辑器中插入DIALOGBAR资源,并为每个按钮创建ID。将它命名为IDD_MENU   
      在资源编辑器编辑String   Table,按钮ID将它命名为ID_VIEW_MENU   
        
      step2:   
      在对话框变量中添加一个DIALOGBAR变量。   
      CDialogBar     m_wndDlgBar;   
        
      step3:   
      在CDialog::OnInitDialog中添加如下代码:     
        
        
      //   创建DIALOGBAR并调入资源   
      if   (!m_wndDlgBar.Create(this,   IDD_MENU,   
      CBRS_TOP   |   CBRS_TOOLTIPS   |   CBRS_FLYBY   |   CBRS_HIDE_INPLACE,   
      ID_VIEW_MENU))   
      {   
      TRACE0("Failed   to   create   dialogbar\n");   
      return   -1;   //   fail   to   create   
      }   
        
      CRect   rcClientOld;   //   久客户区RECT   
      CRect   rcClientNew;   //   加入DIALOGBAR后的CLIENT   RECT   
      GetClientRect(rcClientOld);   //     
      //   Called   to   reposition   and   resize   control   bars   in   the   client   area   of   a   window   
      //   The   reposQuery   FLAG   does   not   really   traw   the   Toolbar.     It   only   does   the   calculations.   
      //   And   puts   the   new   ClientRect   values   in   rcClientNew   so   we   can   do   the   rest   of   the   Math.   
      //重新计算RECT大小   
      RepositionBars(ID_VIEW_MENU,ID_VIEW_MENU,0,reposQuery,rcClientNew);   
        
      //   All   of   the   Child   Windows   (Controls)   now   need   to   be   moved   so   the   dialogbar     
                      //does   not   cover   them   up.   
      //所有的子窗口将被移动,以免被DIALOGBAR覆盖   
      //   Offest   to   move   all   child   controls   after   adding   dialogbar   
      //计算移动的距离   
      CPoint   ptOffset(rcClientNew.left-rcClientOld.left,rcClientNew.top-rcClientOld.top);   
        
      CRect   rcChild;   
      CWnd*   pwndChild   =   GetWindow(GW_CHILD);     //得到子窗口   
      while(pwndChild)   //   处理所有子窗口   
      {//移动所有子窗口   
      pwndChild->GetWindowRect(rcChild);   
      ScreenToClient(rcChild);     
      rcChild.OffsetRect(ptOffset);     
      pwndChild->MoveWindow(rcChild,FALSE);     
      pwndChild   =   pwndChild->GetNextWindow();   
      }   
        
      CRect   rcWindow;   
      GetWindowRect(rcWindow);   //   得到对话框RECT   
      rcWindow.right   +=   rcClientOld.Width()   -   rcClientNew.Width();   //   修改对话框尺寸   
      rcWindow.bottom   +=   rcClientOld.Height()   -   rcClientNew.Height();     
      MoveWindow(rcWindow,FALSE);   //   Redraw   Window   
        
      RepositionBars(ID_VIEW_MENU,ID_VIEW_MENU,0);   
      

  6.   

    上面的代码,哪些是能够响应快捷键的?我看了看,似乎出了Create函数以外,其他都是把窗口移来移去的代码。
    请高手赐教。
      

  7.   

    还是要谢谢diudiuqqqq,下次继续帮忙吧,分都给你了吧。