CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 1999
    Location
    Malaysia
    Posts
    60

    what do i have this error message

    I try to crate a class, CComponentObject with the CObject as the base class. Somehow, it generates 125 errors. It seems that the class CcomponentObject is undefined.

    The following is header file.

    #ifndef _COMPONENTOBJ_H_
    #define _COMPONENTOBJ_H_

    class COpAmpCView;
    class COpAmpCDoc;

    class CComponentObj : public CObject
    {
    protected:
    DECLARE_SERIAL(CComponentObj);
    CComponentObj();

    //Constructors
    public:
    CComponentObj( const CRect& position);

    //Attributes
    CRect m_position;
    COpAmpCDoc* m_pDocument;

    //Operations
    virtual void Draw(CDC* pDC);
    virtual void MoveTo(const CRect& position, COpAmpCView* pView = NULL);
    virtual CComponentObj* Clone( COpAmpCDoc* pDoc = NULL);
    virtual void Remove();
    void Invalidate();

    //Implementation
    public:
    virtual ~CComponentObj();
    virtual void Serialize(CArchive& ar);
    #ifdef _DEBUG
    void AssertValid();
    #endif

    // implementation data
    protected:
    BOOL m_bPen;
    LOGPEN m_logpen;

    };

    the following is .cpp file.

    #include "stdafx.h"
    #include "OpAmpCDoc.h"
    #include "OpAmpCView.h"
    #include "ComponentObj.h"
    #include "DrawComponent.h"
    #include "CntrItem.h"

    IMPLEMENT_SERIAL( CComponentObj, CObject, 0)

    CComponentObj::CComponentObj()
    {
    }

    CComponentObj::~CComponentObj()
    {
    }

    CComponentObj::CComponentObj(const CRect& position)
    {
    m_position = position;
    m_pDocument = NULL;

    m_bPen = TRUE;
    m_logpen.lopnStyle = PS_INSIDEFRAME;
    m_logpen.lopnWidth.x = 1;
    m_logpen.lopnWidth.y = 1;
    m_logpen.lopnColor = RGB(0, 0, 255);

    }

    void CComponentObj::Serialize(CArchive& ar)
    {
    CObject::Serialize(ar);
    if (ar.IsStoring())
    {
    ar << m_position;
    ar << (WORD)m_bPen;
    ar.Write(&m_logpen, sizeof(LOGPEN));

    }
    else
    {
    // get the document back pointer from the archive
    m_pDocument = (COpAmpCDoc*)ar.m_pDocument;
    ASSERT_VALID(m_pDocument);
    ASSERT_KINDOF(COpAmpCDoc, m_pDocument);

    WORD wTemp;
    ar >> m_position;
    ar >> wTemp; m_bPen = (BOOL)wTemp;
    ar.Read(&m_logpen,sizeof(LOGPEN));

    }
    }

    void CComponentObj::Remove()
    {
    delete this;
    }

    void CComponentObj:raw(CDC*)
    {
    }

    // position is in logical
    void CComponentObj::MoveTo(const CRect& position, COpAmpCView* pView)
    {
    ASSERT_VALID(this);

    if (position == m_position)
    return;

    if (pView == NULL)
    {
    Invalidate();
    m_position = position;
    Invalidate();
    }
    else
    {
    pView->InvalObj(this);
    m_position = position;
    pView->InvalObj(this);
    }
    m_pDocument->SetModifiedFlag();
    }


    void CComponentObj::Invalidate()
    {
    ASSERT_VALID(this);
    m_pDocument->UpdateAllViews(NULL, HINT_UPDATE_DRAWOBJ, this);
    }

    CDrawObj* CComponentObj::Clone(COpAmpCDoc* pDoc)
    {
    ASSERT_VALID(this);

    CComponentObj* pClone = new CComponentObj(m_position);
    pClone->m_bPen = m_bPen;
    pClone->m_logpen = m_logpen;

    ASSERT_VALID(pClone);

    if (pDoc != NULL)
    pDoc->Add(pClone);

    return pClone;
    }


    #ifdef _DEBUG
    void CComponentObj::AssertValid()
    {
    ASSERT(m_position.left <= m_position.right);
    ASSERT(m_position.bottom <= m_position.top);
    }
    #endif



  2. #2
    Join Date
    Jul 1999
    Location
    Romania - Iasi
    Posts
    558

    Re: what do i have this error message

    as I see forgot to put

    #endif



    to the end of the header file


    Regards,
    Ovidiu


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured