不想让工具条停靠在主窗口上,请指教

解决方案 »

  1.   

    兄弟,我有做好得极像photoshop的工具条的东西。要得话,留下E-mail.
      

  2.   

    如果以0为参数调用EnableDocking函数,而后再调用FloatControlBar函数,就可以了:
    m_wndToolBar.Create(...);
    EnableDocking(CBRS_ALGN_ANY);
    m_wndToolBar.EnableDocking(0);
    FloatControlBar(&m_wndToolBar,CPoint(x,y));
      

  3.   

    The below code enables you floating a toolbar.
    ------------------------------------------------------>
    if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE 
    | CBRS_TOOLTIPS|CBRS_NOALIGN|CBRS_FLYBY) ||
    !m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
    {
    TRACE0("Failed to create toolbar\n");
    return -1;      // fail to create
    }
    EnableDocking(CBRS_ALIGN_ANY);
    m_wndToolBar.EnableDocking(0);         CRect rect;
    GetWindowRect(&rect);
    FloatControlBar(&m_wndToolBar,CPoint(rect.left+10,rect.top+50),CBRS_ALIGN_LEFT);--------------------------------->
    If you also want to delete the mini close box appeared in the floating toolbar
    Here is the solution:
    Derive a class from CToolBar, I called this class CToolBarEx, but you can choose one that suits your needs.  We only need to remove the close button when the toolbar is floating, so check to see if the bar is actually floating, making sure that m_pDockBar is a valid pointer.Add this member variable to your new class: 
    BOOL m_bMenuRemoved;
    This will get set to TRUE when we remove the system menu, ensuring that we only remove the system menu when needed.We will then need to get a pointer to the parent of m_pDockBar to check to see if it is indeed a CDockFrameWnd class so we can safely remove the system menu from the CToolBar.Here is the code: 
    /////////////////////////////////////////////////////////////////////////////
    // CXXToolBar message handlers#include <afxpriv.h>void CXXToolBar::OnWindowPosChanged(WINDOWPOS FAR* lpwndpos)
    {
        CToolBar::OnWindowPosChanged(lpwndpos);
        // should only be called once, when floated.
        if( IsFloating() )
        {
            if( m_pDockBar && !m_bMenuRemoved )
            {
                CWnd* pParent = m_pDockBar->GetParent();
                if( pParent->IsKindOf(RUNTIME_CLASS(CMiniFrameWnd)))
                {
                    pParent->ModifyStyle( WS_SYSMENU, 0, 0 );
                    m_bMenuRemoved = TRUE;
                }
            }
        }
        else if( m_bMenuRemoved ) {
            m_bMenuRemoved = FALSE;
        }
    }