Assertion error in VS 2005 C++
-
I am trying to use a CFrameWnd in my code and I keep getting an assertion error when I try to ShowWindow(SW_SHOW);
CWnd \* tempWnd = new CWnd(); //Create a new CWnd object tempWnd->Attach(p\_adsw\_hwndAcad); //handle to the main window CFPLvlLyrWnd \*mWnd = (CFPLvlLyrWnd\*)(RUNTIME\_CLASS(CFPLvlLyrWnd))->CreateObject(); //CFPLvleLyrWnd is derived from CFrameWnd RECT sizze = CFrameWnd::rectDefault; DWORD dwStyle = WS\_OVERLAPPEDWINDOW; //set up Window size if (mWnd->Create(NULL, "Levels/Layers", dwStyle, sizze, tempWnd, MAKEINTRESOURCE(0) )) { mWnd->m\_parentWHandle = p\_adsw\_hwndAcad; tempWnd->BeginModalState(); mWnd->ShowWindow(SW\_SHOW); } else { AfxMessageBox("LoadFrame failed!"); } HWND tempHandle = tempWnd->Detach(); delete(tempWnd);
This will run in VS 6.0 but in VS 2005 I get an assertion error and the program crashes. What could be the problem? Help me Obi-Wan Kenobi, you're my only hope!:confused:
-
I am trying to use a CFrameWnd in my code and I keep getting an assertion error when I try to ShowWindow(SW_SHOW);
CWnd \* tempWnd = new CWnd(); //Create a new CWnd object tempWnd->Attach(p\_adsw\_hwndAcad); //handle to the main window CFPLvlLyrWnd \*mWnd = (CFPLvlLyrWnd\*)(RUNTIME\_CLASS(CFPLvlLyrWnd))->CreateObject(); //CFPLvleLyrWnd is derived from CFrameWnd RECT sizze = CFrameWnd::rectDefault; DWORD dwStyle = WS\_OVERLAPPEDWINDOW; //set up Window size if (mWnd->Create(NULL, "Levels/Layers", dwStyle, sizze, tempWnd, MAKEINTRESOURCE(0) )) { mWnd->m\_parentWHandle = p\_adsw\_hwndAcad; tempWnd->BeginModalState(); mWnd->ShowWindow(SW\_SHOW); } else { AfxMessageBox("LoadFrame failed!"); } HWND tempHandle = tempWnd->Detach(); delete(tempWnd);
This will run in VS 6.0 but in VS 2005 I get an assertion error and the program crashes. What could be the problem? Help me Obi-Wan Kenobi, you're my only hope!:confused:
LeonardLay wrote:
...I get an assertion error...
What line of what file is asserting?
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
-
I am trying to use a CFrameWnd in my code and I keep getting an assertion error when I try to ShowWindow(SW_SHOW);
CWnd \* tempWnd = new CWnd(); //Create a new CWnd object tempWnd->Attach(p\_adsw\_hwndAcad); //handle to the main window CFPLvlLyrWnd \*mWnd = (CFPLvlLyrWnd\*)(RUNTIME\_CLASS(CFPLvlLyrWnd))->CreateObject(); //CFPLvleLyrWnd is derived from CFrameWnd RECT sizze = CFrameWnd::rectDefault; DWORD dwStyle = WS\_OVERLAPPEDWINDOW; //set up Window size if (mWnd->Create(NULL, "Levels/Layers", dwStyle, sizze, tempWnd, MAKEINTRESOURCE(0) )) { mWnd->m\_parentWHandle = p\_adsw\_hwndAcad; tempWnd->BeginModalState(); mWnd->ShowWindow(SW\_SHOW); } else { AfxMessageBox("LoadFrame failed!"); } HWND tempHandle = tempWnd->Detach(); delete(tempWnd);
This will run in VS 6.0 but in VS 2005 I get an assertion error and the program crashes. What could be the problem? Help me Obi-Wan Kenobi, you're my only hope!:confused:
The assertion error is in File: f:\rtm\vctools\vc7libs\ship\atlmfc\src\mfc\winfrm.cpp Line: 942
-
The assertion error is in File: f:\rtm\vctools\vc7libs\ship\atlmfc\src\mfc\winfrm.cpp Line: 942
what line in
YOUR
code.Maximilien Lincourt Your Head A Splode - Strong Bad
-
what line in
YOUR
code.Maximilien Lincourt Your Head A Splode - Strong Bad
mWnd->ShowWindow(SW_SHOW);
When it gets to this point, the assertion error appears. I stepped into the code for ShowWindow and when it calls the AfxGetThread() it returns a NULL then it gives the assertion error because the return should not be NULL. -
The assertion error is in File: f:\rtm\vctools\vc7libs\ship\atlmfc\src\mfc\winfrm.cpp Line: 942
Show us the code that contains the
ASSERT
!Steve
-
Show us the code that contains the
ASSERT
!Steve
LRESULT CFrameWnd::OnActivateTopLevel(WPARAM wParam, LPARAM lParam)
{
CWnd::OnActivateTopLevel(wParam, lParam);// exit Shift+F1 help mode on activation changes ExitHelpMode();
#ifndef _AFX_NO_OLE_SUPPORT
// allow OnFrameWindowActivate to be sent to in-place items
if (m_pNotifyHook != NULL)
{
// activate when active and when not minimized
m_pNotifyHook->OnActivate(
LOWORD(wParam) != WA_INACTIVE && !HIWORD(wParam));
}
#endif// deactivate current active view **CWinThread \*pThread = AfxGetThread(); //This returns NULL for the thread ASSERT(pThread); //This is where the assertion error occurs.** if (pThread->m\_pMainWnd == this) { CView\* pActiveView = GetActiveView(); if (pActiveView == NULL) pActiveView = GetActiveFrame()->GetActiveView(); if (pActiveView != NULL) pActiveView->OnActivateView(FALSE, pActiveView, pActiveView); }
-
LRESULT CFrameWnd::OnActivateTopLevel(WPARAM wParam, LPARAM lParam)
{
CWnd::OnActivateTopLevel(wParam, lParam);// exit Shift+F1 help mode on activation changes ExitHelpMode();
#ifndef _AFX_NO_OLE_SUPPORT
// allow OnFrameWindowActivate to be sent to in-place items
if (m_pNotifyHook != NULL)
{
// activate when active and when not minimized
m_pNotifyHook->OnActivate(
LOWORD(wParam) != WA_INACTIVE && !HIWORD(wParam));
}
#endif// deactivate current active view **CWinThread \*pThread = AfxGetThread(); //This returns NULL for the thread ASSERT(pThread); //This is where the assertion error occurs.** if (pThread->m\_pMainWnd == this) { CView\* pActiveView = GetActiveView(); if (pActiveView == NULL) pActiveView = GetActiveFrame()->GetActiveView(); if (pActiveView != NULL) pActiveView->OnActivateView(FALSE, pActiveView, pActiveView); }
-
Unfortunately I still haven't found a solution for this problem. I ended up just going back to using VS 6.0 to continue developing my software.