| 
				 (2)画异或矩形函数 
void  CRectGraph::DrawXorRect(int nType,int nPenWidth,int penclr) 
{ 
    LOGBRUSH logBru; 
    CBrush brush; 
    if (m_pView==NULL)    {   return;      } 
    CDC *pDC = NULL; 
    pDC = m_pView->GetDC(); 
    if (pDC==NULL)        {   return;      } 
    CPen pen(nType, nPenWidth,penclr); 
    pDC->SelectObject(pen); 
    logBru.lbStyle = BS_NULL; 
    brush.CreateBrushIndirect(&logBru); 
    pDC->SelectObject(brush); 
    pDC->SetROP2(R2_XORPEN); 
    pDC->Rectangle(m_Rect); 
} 
(3)清除实体矩形函数 
void  CRectGraph::CleanRect() 
{ 
    BOOL bRtn=TRUE; 
    CRect recPaint; 
    if (m_pView==NULL)    {   return;      } 
    //左上点 
    recPaint.left = m_Rect.left-20; 
    recPaint.top = m_Rect.top -20; 
    recPaint.right = m_Rect.left + 20; 
    recPaint.bottom = m_Rect.bottom + 20; 
    recPaint.NormalizeRect(); 
    m_pView->InvalidateRect(&recPaint); 
    m_pView->SendMessage (WM_PAINT); 
    //右上点 
    recPaint.left = m_Rect.left-20; 
    recPaint.top = m_Rect.top -20; 
    recPaint.right = m_Rect.right + 20; 
    recPaint.bottom = m_Rect.top + 20; 
    recPaint.NormalizeRect(); 
    m_pView->InvalidateRect(&recPaint); 
    m_pView->SendMessage (WM_PAINT); 
    //左下点 
    recPaint.left = m_Rect.left-20; 
    recPaint.top = m_Rect.bottom -20; 
    recPaint.right = m_Rect.right + 20; 
    recPaint.bottom = m_Rect.bottom + 20; 
    recPaint.NormalizeRect(); 
    m_pView->InvalidateRect(&recPaint); 
    m_pView->SendMessage (WM_PAINT);     
    //右下点 
    recPaint.left = m_Rect.right-20; 
    recPaint.top = m_Rect.top -20; 
    recPaint.right = m_Rect.right + 20; 
    recPaint.bottom = m_Rect.bottom + 20; 
    recPaint.NormalizeRect(); 
    m_pView->InvalidateRect(&recPaint); 
    m_pView->SendMessage (WM_PAINT);     
} 
(4)鼠标按下函数 
void  CRectGraph::RectLButtonDown(UINT nFlags, CPoint point) 
{ 
    m_lCurPos = JudgePositionInRect(point); 
    if (m_lCurPos != SUBWIN_OUT) 
    { 
        m_bIsDraw = true; 
        CleanRect(); 
        DrawXorRect(0,0,RGB(255,0,0)); 
        m_pntPrev = point; 
    } 
} 			
				 |