怎样通过OnMouseMove,LButtonDown,LButtonUp这三个函数在Ocx控件上画出矩形,好急好急,请大家帮帮我!!!!!!!!!

解决方案 »

  1.   

    呵呵,刚刚做完一个画矩形
    void C3DCityBuilderView::OnLButtonDown(UINT nFlags, CPoint point) 
    {
    // TODO: Add your message handler code here and/or call default

    m_bIsLButtonDown = TRUE;
    m_OldPoint = point;
    LButtonDownPoint = point; switch (m_curTool)
    {

    case ID_MAP_SELECT:
    if(curSelectMove != NULL)
    SetCursor(curSelectMove);
    break;

    case ID_MAP_ZOOMIN:
    if(curZoomInMove != NULL)
    SetCursor(curZoomInMove);
    break;

    case ID_MAP_ZOOMOUT:
    if(curZoomOutMove != NULL)
    SetCursor(curZoomOutMove);
    break; case ID_MAP_PAN:
    if(curPanMove != NULL)
    SetCursor(curPanMove);
    break; default:
    SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW));
    break;

    }
    CView::OnLButtonDown(nFlags, point);
    }///////////////////////////////////////////////////////////////////////////void C3DCityBuilderView::OnMouseMove(UINT nFlags, CPoint point) 
    {
    // TODO: Add your message handler code here and/or call default
    CDC *pdc = GetDC();
    CRect rect; if(m_bIsLButtonDown)
    { switch (m_curTool)
    {
    case ID_MAP_SELECT:
    if(curSelectMove != NULL)
    // SetCursor(curSelectMove);
    break;

    case ID_MAP_ZOOMIN:
    if(curZoomInMove != NULL)
    SetCursor(curZoomInMove);
    DrawRect(pdc,point); break;

    case ID_MAP_ZOOMOUT:
    if(curZoomOutMove != NULL)
    SetCursor(curZoomOutMove);
    DrawRect(pdc,point);

    break;

    case ID_MAP_PAN:
    if(curPanMove != NULL)
    SetCursor(curPanMove);
    break;

    default:
    SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW));
    break;

    }
    }
    ReleaseDC(pdc);
    CView::OnMouseMove(nFlags, point);
    }
    ///////////////////////////////////////////////////////////////////////////
    void C3DCityBuilderView::OnLButtonUp(UINT nFlags, CPoint point) 
    {
    // TODO: Add your message handler code here and/or call default
    LButtonUpPoint = point;}///////////////////////////////////////////////////////////////////////////
    /*$功能:用于绘制放大,缩小的边框$*/
    void C3DCityBuilderView::DrawRect(CDC * pdc,CPoint point)
    { CRect rect;
    rect.SetRect(LButtonDownPoint.x, LButtonDownPoint.y, m_OldPoint.x, m_OldPoint.y);
    if(m_bIsLButtonDown == 100)
    {
    rect.NormalizeRect();
    pdc->DrawFocusRect(&rect);
    }
    else 
    m_bIsLButtonDown = 100;

    rect.SetRect(LButtonDownPoint.x,LButtonDownPoint.y,point.x,point.y);
    rect.NormalizeRect();
    pdc->DrawFocusRect(&rect);
    m_OldPoint = point;
    }