Hi all,
In my MDI when i try to execute i am getting an assertion error pointing to wincore.cpp line 311.

BOOL CWnd::Attach(HWND hWndNew)
	ASSERT(m_hWnd == NULL);     // only attach once, detach on destroy
	ASSERT(FromHandlePermanent(hWndNew) == NULL);
		// must not already be in permanent map

here is the snippet of the mfc inbuilt code where the assertion error occurs.
The error occurs when the main window is tried to display(attach).

This is the part of the code in the application where the assertion error occurs.

if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
		return FALSE;

Could you please help me to weed out the possible cause of this assertion error

5 Years
Discussion Span
Last Post by raptr_dflo

The error is occurring because CWnd::Attach() is requiring an internal window-handle object to be NULL ... that is, presumably, not already initialized in some other way.

I suspect your problem may be that you're calling pMainFrame->LoadFrame() more than once (maybe inside a loop?), or possibly making some other call that initializes CWnd's internal window-handle object.

If you still can't figure it out, please post a bit more of your own code (especially preceding the 2 lines you've provided so far). Thanks!

SetDialogBkColor();        // Set dialog background color to gray
	LoadStdProfileSettings();  // Load standard INI file options (including MRU)
    m_bCtl3dRegistered = TRUE;

	// create main MDI Frame window
	CMainFrame* pMainFrame = new CMainFrame;
	if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
		return FALSE;

This is the part of the code where the exception occured

	// Instantiate GPPrint.exe
 	HWND hPrint = ::FindWindow("PPrint", NULL);

This is the part of the constructor of CMainframe.
Also i tried by commenting out the code present in the constructor bust still got the same error. am using vc++ 6.0

Edited by kumarmpk4u: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.