Not logged in, Join Here! or Log In Below:  
 
News Articles Search    
 

 Home / General Programming / MFC View class undefined errors Account Manager
 
Archive Notice: This thread is old and no longer active. It is here for reference purposes. This thread was created on an older version of the flipcode forums, before the site closed in 2005. Please keep that in mind as you view this thread, as many of the topics and opinions may be outdated.
 
Sfpiano

May 12, 2005, 04:59 PM

  1.  
  2. #include "stdafx.h"
  3. #include "afxwin.h"
  4.  
  5. class COrthographic : public CView {
  6. protected:
  7.         COrthographic();
  8.         virtual ~COrthographic();
  9.         DECLARE_DYNCREATE(COrthographic)
  10.  
  11.         virtual void OnDraw(CDC* pDC);
  12.         DECLARE_MESSAGE_MAP()
  13. };
  14.  
  15. class CPerspective : public COrthographic {
  16. protected:
  17.         CPerspective();
  18.         virtual ~CPerspective();
  19.         DECLARE_DYNCREATE(CPerspective)
  20.  
  21.         DECLARE_MESSAGE_MAP()
  22. };
  23.  



With this code I get: 'COrthographic' : base class undefined pointing to the first line of the perspective class. What am I missing here?

 
etienne2005

May 12, 2005, 05:47 PM


Here is a sample code that would work (taken from Code Project)
The only difference I can see is that the constructor
and destructor are public...
Do you have the function :
CMyView::CMyView(){

}
CMyView::~CMyView(){

}
somewhere in the cpp file ?


class CMyView : public CView
{

public:
CMyView();
virtual ~CMyView();

public:
int m_idView;

protected:
DECLARE_DYNCREATE(CMyView)

// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CMyView)
protected:
virtual void OnDraw(CDC* pDC); // overridden to draw this view
//}}AFX_VIRTUAL


// Generated message map functions
protected:
//{{AFX_MSG(CMyView)
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};

 
Sfpiano

May 12, 2005, 06:03 PM

Changing it to public didn't change anything.

 
Sfpiano

May 12, 2005, 06:51 PM

Ok, I got it working, except that everything around the edge of my screen flashes.

 
etienne2005

May 12, 2005, 06:59 PM


When you use DECLARE DYNAMIC CREATE macro you have to use
some sort of DEFINE DYNAMIC macro in the
definition (in the cpp file)

This site link seems to use the same kind of class
maybe you should check in the cpp file that implement the
DECLARE, you should have a DEFINE macro somewhere to go with it

http://www.thecodeproject.com/docview/dynviews.asp

It's an automatic DECLARE but you have to DEFINE it somewhere...

Can't you use a Class Wizard in your compiler to do this ?

Good luck :-)

 
This thread contains 5 messages.
 
 
Hosting by Solid Eight Studios, maker of PhotoTangler Collage Maker.