Change CView to CEditView causes assertion 
Author Message
 Change CView to CEditView causes assertion

I am relatively new to MFC programming (though not to C and C++
) and may have attempted something unwise in MFC.  After getting
a program to successfully download a file from the net, I changed
the view from CView to CEditView by changing the base class in the
View's .h file.  The program compiles just fine, but when I try to
execute it, I get a "Debug Assertion Failed" in viewedit.cpp, line
508.  Here is the code from viewedit.cpp where the arrow points
to line 508:

void CEditView::OnPrepareDC(CDC* pDC, CPrintInfo* pInfo)
{
        ASSERT_VALID(this);
        ASSERT_VALID(pDC);
->   ASSERT(pInfo != NULL);  // overriding OnPaint -- never get
this.

        if (pInfo->m_nCurPage > (UINT)m_aPageStart.GetSize() &&
                !PaginateTo(pDC, pInfo))
        {
                // can't paginate to that page, thus cannot print it.
                pInfo->m_bContinuePrinting = FALSE;
        }
        ASSERT_VALID(this);

Quote:
}

In changing the view base class, what else needs to be done?  Or
do I need to start over from scratch and let the wizards do this?

Thanks,
Jim



Tue, 21 Aug 2001 03:00:00 GMT  
 Change CView to CEditView causes assertion
Jim:

When you change the base class, you must change ALL occurrences of
"CView" with "CEditView" in BOTH the .h and .cpp files. I have not used
CEditView, but this certainly works for changing CView to CScrollView.

If this does not work, try making yourself a new dummy SDI application
using CEditView (you can change view class on the last screen of
AppWizard) and look at the generated code to see what it different from
what you have.

Or as you say, you can start over.

HTH,

David Wilkinson

==================

Quote:

> I am relatively new to MFC programming (though not to C and C++
> ) and may have attempted something unwise in MFC.  After getting
> a program to successfully download a file from the net, I changed
> the view from CView to CEditView by changing the base class in the
> View's .h file.  The program compiles just fine, but when I try to
> execute it, I get a "Debug Assertion Failed" in viewedit.cpp, line
> 508.  Here is the code from viewedit.cpp where the arrow points
> to line 508:

> void CEditView::OnPrepareDC(CDC* pDC, CPrintInfo* pInfo)
> {
>         ASSERT_VALID(this);
>         ASSERT_VALID(pDC);
> ->      ASSERT(pInfo != NULL);  // overriding OnPaint -- never get
> this.

>         if (pInfo->m_nCurPage > (UINT)m_aPageStart.GetSize() &&
>                 !PaginateTo(pDC, pInfo))
>         {
>                 // can't paginate to that page, thus cannot print it.
>                 pInfo->m_bContinuePrinting = FALSE;
>         }
>         ASSERT_VALID(this);
> }

> In changing the view base class, what else needs to be done?  Or
> do I need to start over from scratch and let the wizards do this?

> Thanks,
> Jim



Tue, 21 Aug 2001 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. lParam causes an Assertion when changed (PROPSHEETPAGE)

2. Questions about CView / CScrollView / CEditView

3. CView / CEditView

4. CView / CEditView

5. DLL and Threads - causing assertion

6. Why does this function cause an assertion failure?

7. ODBC CRecordset::MoveNext() causing AFXDB.inl assertion

8. CRecordset Open causes assertion

9. free() causes: "Debug Assertion Failed"

10. Allocating/Deallocating Memory in a DLL and EXE causes Assertion-Error

11. delete operator causing assertion failure

12. Accessing ComboBox in dialog box causes an Assertion failure

 

 
Powered by phpBB® Forum Software