ToolBar in MDIChild Window

Posted on 2003-02-19
Medium Priority
Last Modified: 2013-11-20

I am trying to create a toolbar in the MDIChildWnd, so that everytime i create a new child window, i get the same toolbar on each child window.

Question by:pritpal_s_sandhu
1 Comment
LVL 12

Accepted Solution

migel earned 400 total points
ID: 7986669
to do that you need to derive your class from CMDIChildWindow and insert Toolbar creation in the OnCreate method.
here is example:

class CToolBarChildFrame : public CMDIChildWnd
     CToolBarChildFrame();           // protected constructor used by dynamic creation
     CToolBar m_wndMenuBar;
// Attributes

// Operations

// Overrides
     // ClassWizard generated virtual function overrides
     virtual BOOL PreTranslateMessage(MSG* pMsg);

// Implementation
     virtual ~CToolBarChildFrame();

     // Generated message map functions
     afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
     afx_msg void OnSize(UINT nType, int cx, int cy);

here is main methods
int CToolBarChildFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
     if (CMDIChildWnd::OnCreate(lpCreateStruct) == -1)
          return -1;
     if (!m_wndToolBar.CreateEx(this, WS_CHILD | WS_VISIBLE | CBRS_TOP
          !m_wndToolBar.Load(m_nIDHelp))//this have resource ID
          TRACE0("Failed to create menubar\n");
          return -1;      // fail to create
     return 0;

void CToolBarChildFrame::OnSize(UINT nType, int cx, int cy)
     if (IsWindow(m_wndToolBar.m_hWnd))
          if (!m_wndToolBar.IsWindowVisible())
     CMDIChildWnd::OnSize(nType, cx, cy);


Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
How to fix display issue, screen flickering issue when I plug in power cord to the machine. Before I start explaining the solution lets check out once the issue how it looks like after I connect the power cord. most of you also have faced this…
Suggested Courses

621 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question