Inheriting a new View Class for MDI
-
I'm getting an error when I try to inherit a new view class for a MDI application, and I can't figure out why :/ .. First I created an OpenGL viewport inherited from CView, and packed it with all kinds of functionality. It works great. But now I'm trying to derive a new view class from it, and I'm getting the following error (using VC++ 6.0 professional): C:\DEVELOPMENT\MotionX\MotionX.cpp(119) : error C2039: 'classCMotionXModelView' : is not a member of 'CMotionXModelView' c:\development\motionx\motionxmodelview.h(15) : see declaration of 'CMotionXModelView' C:\DEVELOPMENT\MotionX\MotionX.cpp(119) : error C2065: 'classCMotionXModelView' : undeclared identifier The thing is, I'm just deriving it from a class that is fully functional, and haven't added anything except a member variable to it. This is the view class declaration that works:
#if !defined(AFX_MOTIONXGLVIEW_H__A90B4B55_D9F7_4DD4_A776_7EDC323D4724__INCLUDED_) #define AFX_MOTIONXGLVIEW_H__A90B4B55_D9F7_4DD4_A776_7EDC323D4724__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 // MotionXGLView.h : header file // #include "gl/gl.h" #include "gl/glu.h" #include "gl/glaux.h" #include "MotionXSceneDoc.h" #include "MotionXCamera.h" #include "MotionXModel.h" // Added by ClassView ///////////////////////////////////////////////////////////////////////////// // CMotionXGLView view // Define Viewport modes #define PERSPECTIVE 0 #define FRONT 1 #define BACK 2 #define LEFT 3 #define RIGHT 4 #define TOP 5 #define BOTTOM 6 class CMotionXGLView : public CView { protected: CMotionXGLView(); // protected constructor used by dynamic creation DECLARE_DYNCREATE(CMotionXGLView) // Attributes public: // Operations public: CMotionXModel model; void DrawGrid(); void SwitchViewportMode(unsigned int); void DollyViewport(const float speed); void PitchAroundPoint(const float speed); void RotateAroundPoint(const float speed); inline void PedistalViewport(float speed); inline void StrafeViewport(float speed); CMotionXCamera viewCam; BOOL SetupPixelFormat(); // Overrides // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(CMotionXGLView) public: virtual void OnInitialUpdate(); protected: virtual void OnDraw(CDC* pDC); // overridden to draw this view virtual void OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint); virtual BOOL PreCreateWindow(CREATESTRUCT& cs); virtual BOOL OnCommand(WPARAM wP
-
I'm getting an error when I try to inherit a new view class for a MDI application, and I can't figure out why :/ .. First I created an OpenGL viewport inherited from CView, and packed it with all kinds of functionality. It works great. But now I'm trying to derive a new view class from it, and I'm getting the following error (using VC++ 6.0 professional): C:\DEVELOPMENT\MotionX\MotionX.cpp(119) : error C2039: 'classCMotionXModelView' : is not a member of 'CMotionXModelView' c:\development\motionx\motionxmodelview.h(15) : see declaration of 'CMotionXModelView' C:\DEVELOPMENT\MotionX\MotionX.cpp(119) : error C2065: 'classCMotionXModelView' : undeclared identifier The thing is, I'm just deriving it from a class that is fully functional, and haven't added anything except a member variable to it. This is the view class declaration that works:
#if !defined(AFX_MOTIONXGLVIEW_H__A90B4B55_D9F7_4DD4_A776_7EDC323D4724__INCLUDED_) #define AFX_MOTIONXGLVIEW_H__A90B4B55_D9F7_4DD4_A776_7EDC323D4724__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 // MotionXGLView.h : header file // #include "gl/gl.h" #include "gl/glu.h" #include "gl/glaux.h" #include "MotionXSceneDoc.h" #include "MotionXCamera.h" #include "MotionXModel.h" // Added by ClassView ///////////////////////////////////////////////////////////////////////////// // CMotionXGLView view // Define Viewport modes #define PERSPECTIVE 0 #define FRONT 1 #define BACK 2 #define LEFT 3 #define RIGHT 4 #define TOP 5 #define BOTTOM 6 class CMotionXGLView : public CView { protected: CMotionXGLView(); // protected constructor used by dynamic creation DECLARE_DYNCREATE(CMotionXGLView) // Attributes public: // Operations public: CMotionXModel model; void DrawGrid(); void SwitchViewportMode(unsigned int); void DollyViewport(const float speed); void PitchAroundPoint(const float speed); void RotateAroundPoint(const float speed); inline void PedistalViewport(float speed); inline void StrafeViewport(float speed); CMotionXCamera viewCam; BOOL SetupPixelFormat(); // Overrides // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(CMotionXGLView) public: virtual void OnInitialUpdate(); protected: virtual void OnDraw(CDC* pDC); // overridden to draw this view virtual void OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint); virtual BOOL PreCreateWindow(CREATESTRUCT& cs); virtual BOOL OnCommand(WPARAM wP
NTense wrote: //DECLARE_DYNCREATE(CMotionXModelView); Uncomment this in your derived class, and add
IMPLEMENT_DYNCREATE(CMotionXModelView, CMotionXGLView)
in your .cpp fileRyan
"Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"