Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How to create floating toolbar that always active in MFC application

How to create floating toolbar that always active in MFC application

Scheduled Pinned Locked Moved C / C++ / MFC
c++tutorialquestion
1 Posts 1 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Member 11125624
    wrote on last edited by
    #1

    I' m new with MFC. I needed to create a floating toolbar (CToolBar) with no option of docking and save and restore its last pos. The toolbar also should be active all the time, but its NOT. When I'm openning a new child window (dialog for instance) from the mainframe, the floating tool bar become not active (I can not click on its buttons, or drag it etc..). In the past I've used CDialog with Overlapped style and it was floating and always active as I needed. Is it possible to do the same with my Floating Toolbar? Thanks

    int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
    {
    if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
    return -1;

    toolbarIconSize.cx = toolbarIconSize.cy = TOOLBAR_MAIN_ICON_SIZE;
    if ( !m_wndMyFloatingToolbar.Create(this,m_wndMyFloatingToolbar.GetBarStyle() |WS_EX_PALETTEWINDOW | WS_EX_TOPMOST |CBRS_FLOATING | WS_VISIBLE) ||
    !m_wndMyFloatingToolbar.LoadToolBar(IDR_GENERAL_TOOLBAR, toolbarIconSize))
    {
    TRACE0("Failed to create My Floating Toolbar\n");
    return -1; // fail to create
    }

    m_wndMyFloatingToolbar.EnableDocking(0);
    EnableDocking(0);

    if (!CreateCtrlBar())
    {
    TRACE0("Failed to create ctrl toolbar\n");
    return -1; // fail to create
    }

    // ...
    //...
    return 0;
    }

    void CMainFrame::OnViewToolBar()
    {
    // ...
    //...

    CPoint Pos = MyFloatingToolbarGetLastPosition(); \\Get last pos
    FloatControlBar( &m_wndMyFloatingToolbar, Pos, CBRS_ALIGN_LEFT );
    MyFloatingToolbarSetIsVisible();
    FloatControlBar( &m_wndMyFloatingToolbar, Pos, CBRS_ALIGN_LEFT );
    }
    void CMainFrame::MyFloatingToolbarSetIsVisible()
    {
    WINDOWPLACEMENT wp;
    m_wndMyFloatingToolbar.GetParent()->GetParent()->GetWindowPlacement(&wp);
    wp.showCmd = SW_SHOW;
    m_wndMyFloatingToolbar.GetParent()->GetParent()->SetWindowPlacement(&wp);

    m_wndMyFloatingToolbar.GetParent()->GetWindowPlacement(&wp);
    wp.showCmd = SW_SHOW;
    m_wndMyFloatingToolbar.GetParent()->SetWindowPlacement(&wp);

    m_wndMyFloatingToolbar.GetWindowPlacement(&wp);
    wp.showCmd = SW_SHOW;
    m_wndMyFloatingToolbar.SetWindowPlacement(&wp);
    }
    void CWJToolBar::OnWindowPosChanging(WINDOWPOS FAR* lpwndpos)
    {
    CToolBar::OnWindowPosChanging(lpwndpos);

    if ( GetBarStyle() & CBRS_FLOATING )
    {
    if((lpwndpos->flags & SWP_HIDEWINDOW) && ((this->GetParentFrame())->m_hWnd !=(this->GetTopLevelFrame())->m_hWnd))
    {
    CMainFrame* mf = (CMainFrame*)(AfxG

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups