Why my second frame always crashes when I select it?

My first frame window is based on this instance:
       CMultiDocTemplate* pDocTemplate;
      pDocTemplate = new CChartDocTemplate(
            RUNTIME_CLASS(CChildFrame),      // custom MDI child frame
All the client view from this frame has the same ToolBar.
Since I don't want my client window has the same ToolBar, I create another frame like:

      CMultiDocTemplate* pVolumePriceTemplate;
      pVolumePriceTemplate = new CChartDocTemplate(
            RUNTIME_CLASS(CVolumePriceFrame), // custom MDI child frame

My question is that:

1- Do I need to create another frame so that my client window has different ToolBar? How Do I it?
2- Why my second frame always crashes when activated?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

How do you create the second frame? Can you post the code?

Have you add a menu and icon resources with ID = IDR_VOLUMEPRICE?

If you add the toolbar to the child window in the way I explained at http://www.experts-exchange.com/Programming/System/Windows__Programming/Q_23087034.html you must chenge the ID of the toolbar resources when you call LoadToolBar();
xtran888Author Commented:
This is the header file for CVolumePriceFrame:

class CStyleBar : public CToolBar
      CComboBox   m_comboBox;
      CFont       m_font;

class CVolumePriceFrame : public CMDIChildWnd

// Attributes
//      CToolBar   m_wndToolBar;
//      CComboBox   m_comboBox;
      CStyleBar   m_wndStyleBar;

// Operations

// Overrides
      // ClassWizard generated virtual function overrides
      virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
//      virtual BOOL Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle = WS_CHILD | WS_VISIBLE | WS_OVERLAPPEDWINDOW, const RECT& rect = rectDefault, CMDIFrameWnd* pParentWnd = NULL, CCreateContext* pContext = NULL);

// Implementation
      virtual ~CVolumePriceFrame();
#ifdef _DEBUG
      virtual void AssertValid() const;
      virtual void Dump(CDumpContext& dc) const;

// Generated message map functions
      afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
      afx_msg void OnCombo();
And its code:
#include "stdafx.h"
#include "ChartApp.h"

#include "VolumePriceFrm.h"
#include "resource.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;

// CVolumePriceFrame


BEGIN_MESSAGE_MAP(CVolumePriceFrame, CMDIChildWnd)

// CVolumePriceFrame construction/destruction



BOOL CVolumePriceFrame::PreCreateWindow(CREATESTRUCT& cs)

      return CMDIChildWnd::PreCreateWindow(cs);

// CVolumePriceFrame diagnostics

#ifdef _DEBUG
void CVolumePriceFrame::AssertValid() const

void CVolumePriceFrame::Dump(CDumpContext& dc) const

#endif //_DEBUG

// CVolumePriceFrame message handlers

int CVolumePriceFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
      if (CMDIChildWnd::OnCreate(lpCreateStruct) == -1)
            return -1;


      if (!m_wndStyleBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
            TRACE0("Impossibile creare la barra degli strumenti.\n");
            return -1;

        int i=0;
        while (m_wndStyleBar.GetItemID (i++) == IDW_COMBO)

      const int nDropHeight = 100;
      CRect rect;
      m_wndStyleBar.GetItemRect (0, &rect);
      rect.top = 3;
      rect.bottom = rect.top + nDropHeight;
      if (!m_wndStyleBar.m_comboBox.Create(
                  rect, &m_wndStyleBar, IDW_COMBO))
            TRACE0("Failed to create combo-box\n");
            return FALSE;
      m_wndStyleBar.m_comboBox .AddString ("list1 ");
      m_wndStyleBar.m_comboBox .AddString ("list2 ");
      m_wndStyleBar.m_comboBox .AddString ("lsit3 ");
        // TODO: Add your specialized creation code here
      return 0;

void CVolumePriceFrame::OnCombo()
      // TODO: Add your command handler code here
      CString myString;
      m_wndStyleBar.m_comboBox .GetDlgItemText (0, myString);
I did change the ID of the toolbar resourcem but the program still crashes.
xtran888Author Commented:
Is there anybody can help me to solve this question that was posted since Friday?
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

Give a look at http://www.experts-exchange.com/Programming/System/Windows__Programming/MFC/Q_23075242.html
It can help to create a new window from a different template.
xtran888Author Commented:
I found out that my frame window (CVolumePriceFrame) is derived from CMDIChildWnd instead of
CFrameWnd. Now it is working now.
PAQed with points refunded (500)

EE Admin

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.