Wincore Debug assertion failed

M

Mullai

Hi ,
My program gives an error message like this

Debug Assertion Failed!
program:................
File: wincore.cpp
Line: 958

Please can anyone help me out in this issue. I have to solve this bug
immediately in my project.
The line 958 is as follows in wincore.cpp

When I am trying to close my window created CFrameWnd class by calling
DestroyWindow() this assertion has been asserted.

BOOL CWnd::DestroyWindow()
{
if (m_hWnd == NULL)
return FALSE;

CHandleMap* pMap = afxMapHWND(); ///// line 958/////
ASSERT(pMap != NULL);
CWnd* pWnd = (CWnd*)pMap->LookupPermanent(m_hWnd);

Thanks
Mullai
 
D

Doug Forster

Hi,

You wouldn't normally call DestroyWindow for a CFrameWnd. Could you explain
why you are trying to do this and show us some of your code.

Cheers
Doug Forster
 
M

Mullai

first of all Thanku Mr.Doug Forster for ur response.

My scenario is:

In CMainframe class , I add my own class called CChildWindow
which is derived from CScrollview. In CChildWindow I added my own class
called CPagewindow which is been derived from CFrameWnd.The place where
I get error is , While I am trying to close my main application,
CMainframe's OnClose() is called which in turn calls CChildWindow's
OnClose() where the Pagewindow->DestroyWindow() is called. Here only
the assertion occurs.

CMainframe -> CChildWindow -> CPageWindow -> DestroyWindow()

The Code follows as:

void CMainFrame::OnClose()
{

GlobalMembers::m_PageWindowHandle=m_ChildWnd->m_structPgDetails.PageHandle;
m_ChildWnd->OnClose();
CFrameWnd::OnClose();

}

void CChildWindow::OnClose()
{
pagewindow->DestroyWindow();
}

///// Asserts here in destroy window
Debug Assertion Failed!/////
 
D

Doug Forster

Hi,

Well I don't fully understand your window structure, but usually if they are
all parented correctly you shouldn't need to do anything special to close
child windows - the MFC infrastructure will handle it. So the first thing to
try is simply commenting out much of your closing code - the assertion is
just telling you that the window is already gone. If for some reason you DO
need to explicitly close a window then the usual way is to simply Post a
WM_CLOSE and let the infrastructure handle the rest. Usually the only
situation you need to explicitly call DestroyWindow in MFC is during the
shutdown handling of a modeless dialog.

Cheers
Doug Forster

Mullai said:
first of all Thanku Mr.Doug Forster for ur response.

My scenario is:

In CMainframe class , I add my own class called CChildWindow
which is derived from CScrollview. In CChildWindow I added my own class
called CPagewindow which is been derived from CFrameWnd.The place where
I get error is , While I am trying to close my main application,
CMainframe's OnClose() is called which in turn calls CChildWindow's
OnClose() where the Pagewindow->DestroyWindow() is called. Here only
the assertion occurs.

CMainframe -> CChildWindow -> CPageWindow -> DestroyWindow()

The Code follows as:

void CMainFrame::OnClose()
{

GlobalMembers::m_PageWindowHandle=m_ChildWnd->m_structPgDetails.PageHandle;
m_ChildWnd->OnClose();
CFrameWnd::OnClose();

}

void CChildWindow::OnClose()
{
pagewindow->DestroyWindow();
}

///// Asserts here in destroy window
Debug Assertion Failed!/////
Doug said:
Hi,

You wouldn't normally call DestroyWindow for a CFrameWnd. Could you
explain
why you are trying to do this and show us some of your code.

Cheers
Doug Forster
 
M

Mullai

Hi,

I tried by sending a window Message (WM_CLOSE) . Even then the
problem occurred. I then found out this error is because of the current
thread state. SO I added AFX_MANAGE_STATE(Afxgetappmodulestate())
before the window message. The problem is solved.

THANK U FOR YOUR KIND HELP.

REGARDS,
Mullai.P


Doug said:
Hi,

Well I don't fully understand your window structure, but usually if they are
all parented correctly you shouldn't need to do anything special to close
child windows - the MFC infrastructure will handle it. So the first thing to
try is simply commenting out much of your closing code - the assertion is
just telling you that the window is already gone. If for some reason you DO
need to explicitly close a window then the usual way is to simply Post a
WM_CLOSE and let the infrastructure handle the rest. Usually the only
situation you need to explicitly call DestroyWindow in MFC is during the
shutdown handling of a modeless dialog.

Cheers
Doug Forster

Mullai said:
first of all Thanku Mr.Doug Forster for ur response.

My scenario is:

In CMainframe class , I add my own class called CChildWindow
which is derived from CScrollview. In CChildWindow I added my own class
called CPagewindow which is been derived from CFrameWnd.The place where
I get error is , While I am trying to close my main application,
CMainframe's OnClose() is called which in turn calls CChildWindow's
OnClose() where the Pagewindow->DestroyWindow() is called. Here only
the assertion occurs.

CMainframe -> CChildWindow -> CPageWindow -> DestroyWindow()

The Code follows as:

void CMainFrame::OnClose()
{

GlobalMembers::m_PageWindowHandle=m_ChildWnd->m_structPgDetails.PageHandle;
m_ChildWnd->OnClose();
CFrameWnd::OnClose();

}

void CChildWindow::OnClose()
{
pagewindow->DestroyWindow();
}

///// Asserts here in destroy window
Debug Assertion Failed!
program:................
File: wincore.cpp
Line: 958
/////
Doug said:
Hi,

You wouldn't normally call DestroyWindow for a CFrameWnd. Could you
explain
why you are trying to do this and show us some of your code.

Cheers
Doug Forster

Hi ,
My program gives an error message like this

Debug Assertion Failed!
program:................
File: wincore.cpp
Line: 958

Please can anyone help me out in this issue. I have to solve this bug
immediately in my project.
The line 958 is as follows in wincore.cpp

When I am trying to close my window created CFrameWnd class by calling
DestroyWindow() this assertion has been asserted.

BOOL CWnd::DestroyWindow()
{
if (m_hWnd == NULL)
return FALSE;

CHandleMap* pMap = afxMapHWND(); ///// line 958/////
ASSERT(pMap != NULL);
CWnd* pWnd = (CWnd*)pMap->LookupPermanent(m_hWnd);

Thanks
Mullai
 
Joined
Mar 25, 2007
Messages
1
Reaction score
0
Assertion Error in Wincore.cpp

Hi

How did you fix this problem ? I have this problem my self, when i try to close my mainframe window, i get this error and the .exe still running, the main window is closed but i get this assertion in wincore.cpp and the .exe fil still running, i had to open task manager and close the .exe fil from there.

Where did you post the WM_CLOSE messages, can you please show me all the codes you used ? It will be very useful for me to solve my problem.

Thank you very much in advance

Best regards

Luc
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top