2

I've making simple desktop game in mfc for school project, I've managed to make my app be full screen and to remove menu bar but I can't find out how to remove default built in toolbar from my app or status bar. I tried everything that came across my mind...is there some kind of get function to call from your CWnd object to retrieve toolbar and status bar?

3 Answers 3

2

The creation of ToolBar and StatusBar is inside the CMainFrame class. You can easily remove them if you do not need them as follows:

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

    // *** creation of ToolBar starts, just remark/delete the whole block if you dont't want it
    if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
        | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
        !m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
    {
        TRACE0("Failed to create toolbar\n");
        return -1;      // fail to create
    }
    // *** creation of ToolBar  ends -------------------------------------------------------

    // *** creation of StatusBar starts, just remark/delete the whole block if you dont't want it
    if (!m_wndStatusBar.Create(this) ||
        !m_wndStatusBar.SetIndicators(indicators,
          sizeof(indicators)/sizeof(UINT)))
    {
        TRACE0("Failed to create status bar\n");
        return -1;      // fail to create
    }
    // *** creation of StatusBar ends -------------------------------------------------------

    // *** you have to remark/delete these lines too, if you removed the ToolBar above
    m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
    EnableDocking(CBRS_ALIGN_ANY);
    DockControlBar(&m_wndToolBar);
    // *** ToolBar extra ends -------------------------------------------------------

    return 0;

}

2

m_pMainWnd->SetMenu(NULL); right before m_pMainWnd->ShowWindow(SW_SHOW); is called in the APPLICATION_NAME.cpp file.

1

Go to your resource file, double click on it , locate the toolbar, right click on it and choose delete :)

enter image description here

4
  • i've managed to do it from code. But even so I can't remove status bar. Mar 30, 2013 at 16:14
  • code to remove toolbar is: CWnd* pWnd = AfxGetMainWnd()->ChildWindowFromPoint(CPoint(5, 5), CWP_SKIPINVISIBLE); pWnd->ShowWindow(SW_HIDE); Mar 30, 2013 at 16:15
  • This link codeguru.com/cpp/controls/statusbar/article.php/c2979/… contains some snippets how to remove the status bar (this is based on intercepting the relevant WM) Mar 30, 2013 at 16:19
  • i've checked your link, it's no help to me, all my code is in CView class and I control displayed content by AfxGetMainWnd() function which return CWnd object, I don't have CMainFrame class access. But thanks anyway Mar 30, 2013 at 16:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.