Click to See Complete Forum and Search --> : Assertion Error While Creating MDI Window


Balasubramaniam.j
March 28th, 1999, 11:02 AM
I have tired to create mdi window in two ways but in both the case it is

displaying the same error and if i ignore it it is displaying the mdi window please any one of you solve it for me

and tell me what is the mistake that i have done so i could rectify it.

i am enclosing my code below.

prog 1

#include<afxwin.h>

#include<afxext.h>

#include "resource.h"

class Win:public CWinApp

{

public:

BOOL InitInstance();

};

class Frame:public CMDIFrameWnd

{

public:

Frame();

afx_msg int PreCreateWindow(CREATESTRUCT &cs);

afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);

DECLARE_MESSAGE_MAP()

};

BEGIN_MESSAGE_MAP(Frame,CMDIFrameWnd)

ON_WM_CREATE()

END_MESSAGE_MAP()

Frame::Frame()

{

}

int Frame::OnCreate(LPCREATESTRUCT lpCreateStruct)

{

if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)

return -1;

return 0;

}

int Frame::PreCreateWindow(CREATESTRUCT &cs)

{

return CMDIFrameWnd::PreCreateWindow(cs);

}

BOOL Win::InitInstance()

{

Frame* pMainFrame = new Frame;

if (!pMainFrame->LoadFrame(IDR_MAINFRAME))

return FALSE;

m_pMainWnd = pMainFrame;

m_pMainWnd->ShowWindow(3);

m_pMainWnd->UpdateWindow();

return TRUE;

}

Win w1;

resource.h

//{{NO_DEPENDENCIES}}

// Microsoft Developer Studio generated include file.

// Used by Script2.rc

//

#define IDR_MENU1 101

#define IDR_MAINFRAME 101

#define ID_MENUITEM40001 40001

#define ID_MENUITEM40002 40002

#define ID_MENUITEM40003 40003

#define ID_MENUITEM40004 40004

// Next default values for new objects

//

#ifdef APSTUDIO_INVOKED

#ifndef APSTUDIO_READONLY_SYMBOLS

#define _APS_NEXT_RESOURCE_VALUE 102

#define _APS_NEXT_COMMAND_VALUE 40005

#define _APS_NEXT_CONTROL_VALUE 1000

#define _APS_NEXT_SYMED_VALUE 101

#endif

#endif

Bore
March 28th, 1999, 01:36 PM
What error are you getting? Where does the assert occur? What are you trying to do?

Balasubramaniam.j
March 28th, 1999, 10:00 PM
I have tired to create mdi window in two ways but in both the case it is

displaying the same error and if i ignore it it is displaying the mdi window please any one of you solve it for me

and tell me what is the mistake that i have done so i could rectify it.

i am enclosing my code below.

prog 1

#include<afxwin.h>

#include<afxext.h>

#include "resource.h"

class Win:public CWinApp

{

public:

BOOL InitInstance();

};

class Frame:public CMDIFrameWnd

{

public:

Frame();

afx_msg int PreCreateWindow(CREATESTRUCT &cs);

afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);

DECLARE_MESSAGE_MAP()

};

BEGIN_MESSAGE_MAP(Frame,CMDIFrameWnd)

ON_WM_CREATE()

END_MESSAGE_MAP()

Frame::Frame()

{

}

int Frame::OnCreate(LPCREATESTRUCT lpCreateStruct)

{

if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)

return -1;

return 0;

}

int Frame::PreCreateWindow(CREATESTRUCT &cs)

{

return CMDIFrameWnd::PreCreateWindow(cs);

}

BOOL Win::InitInstance()

{

Frame* pMainFrame = new Frame;

if (!pMainFrame->LoadFrame(IDR_MAINFRAME))

return FALSE;

m_pMainWnd = pMainFrame;

m_pMainWnd->ShowWindow(3);

m_pMainWnd->UpdateWindow();

return TRUE;

}

Win w1;

resource.h

//{{NO_DEPENDENCIES}}

// Microsoft Developer Studio generated include file.

// Used by Script2.rc

//

#define IDR_MENU1 101

#define IDR_MAINFRAME 101

#define ID_MENUITEM40001 40001

#define ID_MENUITEM40002 40002

#define ID_MENUITEM40003 40003

#define ID_MENUITEM40004 40004

// Next default values for new objects

//

#ifdef APSTUDIO_INVOKED

#ifndef APSTUDIO_READONLY_SYMBOLS

#define _APS_NEXT_RESOURCE_VALUE 102

#define _APS_NEXT_COMMAND_VALUE 40005

#define _APS_NEXT_CONTROL_VALUE 1000

#define _APS_NEXT_SYMED_VALUE 101

#endif

#endif

This was the message which i posted earlier and i am getting error message on

winmdi.cpp which is a system file on line number 139,141,151 and when i try to debug

it it is showing iMenu=-1 which should be grater than or equal to zero.

why it is showing error on menu.

The Object of the programme is to create a mdi window with menu.

Thank you

BalaSubramaniam.J

Balasubramaniam.j
March 28th, 1999, 10:08 PM
The Object of my programme is to create a mdi window with a menu but

it is displaying a assertion error on winmdi.cpp which is a system file on

line 139,141,151 and when i try to debug it is displaying error in menu=-1

which should be greater than or equal to zero.

please kindly solve my error

By Balasubramaniam.J

Balasubramaniam.j
March 28th, 1999, 10:15 PM
The Object of my programme is to create a mdi window with a menu but

it is displaying a assertion error on winmdi.cpp which is a system file on

line 139,141,151 and when i try to debug it is displaying error in iMenu=-1

which should be greater than or equal to zero.

ASSERT(iMenu >= 0);

pMenu = pMenu->GetSubMenu(iMenu);

ASSERT(pMenu != NULL)

in the above lines it is displaying error .

please kindly solve my error

Bore
March 29th, 1999, 10:44 AM
I think you should re-post your message with a subject line something like, "How to create a MDI window with a menu." I bet you'll get a lot of responses.