?
Solved

ToolBar in MDIChild Window

Posted on 2003-02-19
3
Medium Priority
?
351 Views
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.

0
Comment
Question by:pritpal_s_sandhu
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 12

Accepted Solution

by:
migel earned 400 total points
ID: 7986669
Hi!
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
{
     DECLARE_DYNCREATE(CToolBarChildFrame)
protected:
     CToolBarChildFrame();           // protected constructor used by dynamic creation
     CToolBar m_wndMenuBar;
// Attributes
public:

// Operations
public:

// Overrides
     // ClassWizard generated virtual function overrides
     //{{AFX_VIRTUAL(CToolBarChildFrame)
     public:
     virtual BOOL PreTranslateMessage(MSG* pMsg);
     //}}AFX_VIRTUAL

// Implementation
protected:
     virtual ~CToolBarChildFrame();

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

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
          | CBRS_GRIPPER | CBRS_SIZE_DYNAMIC) ||
          !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())
               m_wndToolBar.ShowWindow(SW_SHOW);
          }
     CMDIChildWnd::OnSize(nType, cx, cy);
}


0

Featured Post

Percona Live Europe 2017 | Sep 25 - 27, 2017

The Percona Live Open Source Database Conference Europe 2017 is the premier event for the diverse and active European open source database community, as well as businesses that develop and use open source database software.

Question has a verified solution.

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

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Suggested Courses
Course of the Month10 days, 7 hours left to enroll

765 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