在CShiyanView.h中声明如下:
----------------------------------------------
enum ShpType
{shpRectangle,
shpEllipse};
struct Shape
{CRect m_boxShape;
ShpType m_typeShape;
bool m_bTransparent;
};
------------------------------------------------
在CShiyanView.cpp中
 void CShiyanView::OnDraw(CDC* pDC)
 {
CShiyanDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc); for(int nShp=0;nShp<m_countShapes;nShp++)
{
ASSERT(m_arShps[nShp].m_typeShape==shpRectangle||
m_arShps[nShp].m_typeShape==shpEllipse);
         SetPenBrush(pDC,m_arShps[nShp].m_bTransparent);
**6** switch(m_typeShape)
{
**7**  case shpRectangle:pDC->Rectangle(m_boxShape);
break;                                   
 case shpEllipse:pDC->Ellipse(m_boxShape);
break;
      
   default: ;
 }
ResetPenBrush(pDC);
}
 
}
--------------------------------------------------------------------
在**6**和**7**处报错:  m_typeShape:没有声明,和m_boxShape没有声明;

解决方案 »

  1.   

    m_typeShape   ->    m_arShps[ShpType]
      

  2.   

    switch(m_arShps[nShp].m_typeShape)
    {
    **7**  case 'shpRectangle':pDC->Rectangle(m_boxShape);
    break;                                   
     case 'shpEllipse':pDC->Ellipse(m_boxShape);
    break;
          
       default: ;
      

  3.   

    在CShiyanView.h中声明如下:
    ----------------------------------------------
    enum ShpType
    {shpRectangle,
    shpEllipse};
    struct Shape
    {CRect m_boxShape;
    ShpType m_typeShape;
    bool m_bTransparent;
    };------------------------------------------------
    在CShiyanView.cpp中
     void CShiyanView::OnDraw(CDC* pDC)
     {
    CShiyanDoc* pDoc = GetDocument();
    ASSERT_VALID(pDoc); for(int nShp=0;nShp<m_countShapes;nShp++)
    {
    ASSERT(m_arShps[nShp].m_typeShape==shpRectangle||
    m_arShps[nShp].m_typeShape==shpEllipse);
             SetPenBrush(pDC,m_arShps[nShp].m_bTransparent);
    switch(m_arShps[nShp].m_typeShape)
    {
     case shpRectangle:pDC->Rectangle(m_arShps[nShp].m_boxShape);
    break;                                   
     case shpEllipse:pDC->Ellipse(m_arShps[nShp].m_boxShape);
    break;
          
       default: ;
     }
    ResetPenBrush(pDC);
    }
     
    }
      

  4.   

    我的意思是我们用QQ联系,告我你的QQ