Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Assertion error in VS 2005 C++

Assertion error in VS 2005 C++

Scheduled Pinned Locked Moved C / C++ / MFC
helpc++visual-studioquestion
9 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    LeonardLay
    wrote on last edited by
    #1

    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:

    D L 2 Replies Last reply
    0
    • L LeonardLay

      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:

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0
      • L LeonardLay

        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:

        L Offline
        L Offline
        LeonardLay
        wrote on last edited by
        #3

        The assertion error is in File: f:\rtm\vctools\vc7libs\ship\atlmfc\src\mfc\winfrm.cpp Line: 942

        M S 2 Replies Last reply
        0
        • L LeonardLay

          The assertion error is in File: f:\rtm\vctools\vc7libs\ship\atlmfc\src\mfc\winfrm.cpp Line: 942

          M Offline
          M Offline
          Maximilien
          wrote on last edited by
          #4

          what line in YOUR code.

          Maximilien Lincourt Your Head A Splode - Strong Bad

          L 1 Reply Last reply
          0
          • M Maximilien

            what line in YOUR code.

            Maximilien Lincourt Your Head A Splode - Strong Bad

            L Offline
            L Offline
            LeonardLay
            wrote on last edited by
            #5

            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.

            1 Reply Last reply
            0
            • L LeonardLay

              The assertion error is in File: f:\rtm\vctools\vc7libs\ship\atlmfc\src\mfc\winfrm.cpp Line: 942

              S Offline
              S Offline
              Stephen Hewitt
              wrote on last edited by
              #6

              Show us the code that contains the ASSERT!

              Steve

              L 1 Reply Last reply
              0
              • S Stephen Hewitt

                Show us the code that contains the ASSERT!

                Steve

                L Offline
                L Offline
                LeonardLay
                wrote on last edited by
                #7

                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);
                }
                
                W 1 Reply Last reply
                0
                • L LeonardLay

                  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);
                  }
                  
                  W Offline
                  W Offline
                  wipehindy
                  wrote on last edited by
                  #8

                  Did you find a solution for your problem ? Thank you.

                  L 1 Reply Last reply
                  0
                  • W wipehindy

                    Did you find a solution for your problem ? Thank you.

                    L Offline
                    L Offline
                    LeonardLay
                    wrote on last edited by
                    #9

                    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.

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups