使用MFC创建了一个基于对话框的应用程序,运行后出现了一个对话框窗体。现在想在对话框中插入菜单栏和快捷方式栏,,不知道能不能这么创建,我想在这个程序中插入菜单资源和toolbar资源,但是发现资源里没有相关的资源,这是为什么??

解决方案 »

  1.   

    插入即可!
    http://www.vckbase.com/document/viewdoc/?id=657
      

  2.   

    [url=http://www.vckbase.com/document/viewdoc/?id=265]
    在Dialog中使用Menu和Toolbar
      

  3.   

    添加菜单:首先在资源中创建菜单,然后在要添加菜单的对话框属性menu中添加上即可;
    添加工具栏:首先在资源中创建工具栏,然后在对话框头文件中定义一个工具栏对象
    CToolBar m_wndToolBar;//工具条
    然后在对话框OnInitDialog()函数中添加下列代码即可
    /************添加工具条************/
    if(!m_wndToolBar.CreateEx(this,   TBSTYLE_FLAT,   WS_CHILD   |   WS_VISIBLE   |     
    CBRS_TOP|   CBRS_TOOLTIPS   |   CBRS_FLYBY   |   CBRS_SIZE_DYNAMIC)   ||   
    !m_wndToolBar.LoadToolBar(IDR_TOOLBAR1) )   
    {   
    AfxMessageBox("Failed   to   create   toolbar   in   dialog\n");   
    return   -1;   
    }     m_wndToolBar.EnableToolTips(TRUE);

    CRect rcClientOld;   //   旧客户区RECT   
    CRect rcClientNew;   //   加入TOOLBAR后的CLIENT   RECT   
    GetClientRect(rcClientOld);   //     

    //重新计算RECT大小   
    RepositionBars(AFX_IDW_CONTROLBAR_FIRST,AFX_IDW_CONTROLBAR_LAST,0,reposQuery,rcClientNew);      
    //所有的子窗口将被移动,以免被TOOLBAR覆盖   
    //计算移动的距离   
    CPoint   ptOffset(rcClientNew.left-rcClientOld.left,   
    rcClientNew.top-rcClientOld.top-10);   
        
    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();        
        
    RepositionBars(AFX_IDW_CONTROLBAR_FIRST,AFX_IDW_CONTROLBAR_LAST,0);  
    //添加工具条结束