如题

解决方案 »

  1.   

    http://www.vckbase.com/document/viewdoc.asp?id=515
      

  2.   

    不是在CMainFrame框架窗口中!
    是在CWnd类窗口中!
      

  3.   

    以下办法可以在对话框中建立一个工具条,至于浮动什么的,跟FrameWnd里面一样,关键是建立出来 : )m_ToolBar.CreateEx( this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_ALIGN_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS, CRect(4,4,0,0));
    m_ToolBar.LoadToolBar(IDR_TOOLBAR1));m_wndtoolbar.ShowWindow(SW_SHOW);
    RepositionBars(AFX_IDW_CONTROLBAR_FIRST, AFX_IDW_CONTROLBAR_LAST, 0);
      

  4.   

    vckbase第16期
    ----------------------------------
     [ 本文属于第16期, 适合初级读者 ]在对话框程序中插入DialogBar
    作者:徐建鹏下载本文示例源代码程序运行效果图如下:
      在基于MainFrm程序中加入DialogBar很方便,大家都知道,DialogBar有着工具条无法比拟的优越性,它可以任意放置控件,轻松实现如WPS OFFICE的导航功能。但是在基于Dialog的程序怎么实现这种导航功能呢?本文拟针对这个问题提出解决的办法,将困扰本人很久的问题的解决方法和大家一同分享。
    大家都知道,CDialogBar不能在Dialog程序中产生的原因是Dialog中没有MainFrm,所以我就从CMiniFrameWnd产生了自己的一个类CMyMiniFrm。 BOOL CMyMiniFrm::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo) 
    {
    // pass those up in the dialog to leave the OnUpdateUI mechanism to flow
    BOOL br = GetParent()->OnCmdMsg(nID, nCode, pExtra, pHandlerInfo);
    // leave the default proc to handles the tooltip updating mechanism
    CMiniFrameWnd::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo);
    return br; // return what the parent returns
    }然后,我们可以从Cstatic产生自己的生成Cdialog类了,其中创建CDialogBar的代码如下 void CStTbar::PreSubclassWindow() 
    {
    CStatic::PreSubclassWindow();

    RECT rt; GetWindowRect(&rt);
    GetParent()->ScreenToClient(&rt);
    // hide the place holder, no not destro it I need it to rerout the messages
    ShowWindow(SW_HIDE);
    // make it on the heap as long  CMyMiniFrm::OnNcDestroy call ''delete this'' 
    // save me to map one more message
    m_minifrm = new CMyMiniFrm();
    m_minifrm->Create( AfxRegisterWndClass(0,0,0),
    "",WS_VISIBLE|WS_CHILD,rt,GetParent()/*of placeholder*/); {
    // Initialize dialog bar m_wndMyDialogBar
    if (!m_wndMyDialogBar.Create(m_minifrm, GetDlgCtrlID(),
    CBRS_RIGHT | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_HIDE_INPLACE,
    CG_ID_VIEW_MYDIALOGBAR))
    {
    TRACE0("Failed to create dialog bar m_wndMyDialogBar\n");
    return; // fail to create
    } m_wndMyDialogBar.EnableDocking(CBRS_ALIGN_LEFT | CBRS_ALIGN_RIGHT);
    m_minifrm->EnableDocking(CBRS_ALIGN_ANY);
    if(rt.right-rt.left > rt.bottom-rt.top)
    m_minifrm->DockControlBar(&m_wndMyDialogBar,CBRS_ALIGN_LEFT);
    else
    // dock verically
    m_minifrm->DockControlBar(&m_wndMyDialogBar,CBRS_ALIGN_RIGHT);
    m_minifrm->RecalcLayout();
    //m_minifrm->DockControlBar(&m_wndMyDialogBar); }
    }
    然后,我们还要解决消息传递问题。 void CStTbar::PreTranslate(MSG* pMsg)
    {
    // forward this to the toolbar
    // 
    if(m_wndMyDialogBar.IsWindowVisible())
    m_wndMyDialogBar.OnUpdateCmdUI(m_minifrm,TRUE);
    }
    这样一个在对话框中产生DialogBar的类基本完成。
    然后在要使用DialogBar的对话框中增加一个STATIC控件,定义成和准备当作DialogBar使用的Dialog一样的ID号,再给STATIC控件增加CstTbar型的Contrl变量,就可以使用了。 
    另外,我们只要为该DialogBar创建一个类,在该类中就可以像操作普通对话框一样在ClassWizard中对各控件进行操作或处理各种消息。 
      

  5.   

    m_ToolBar.CreateEx( this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_ALIGN_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS, CRect(4,4,0,0));
    m_ToolBar.LoadToolBar(IDR_TOOLBAR1));
    建立的toolbar的tooltips出不来 呜呜
      

  6.   

    yjgx007(谁是高手)--------你是高手,强!
      

  7.   

    m_ToolBar.CreateEx( this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_ALIGN_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS, CRect(4,4,0,0));
    m_ToolBar.LoadToolBar(IDR_TOOLBAR1));m_wndtoolbar.ShowWindow(SW_SHOW);
    RepositionBars(AFX_IDW_CONTROLBAR_FIRST, AFX_IDW_CONTROLBAR_LAST, 0);