視圖選擇區域

void CMyBView::OnLButtonDown(UINT nFlags, CPoint point)
{
 // TODO: Add your message handler code here and/or call default

if (!isrect)
{

   startpoint=point;

   temppoint=point;

   flags=TRUE;

}
 
 CView::OnLButtonDown(nFlags, point);
}

void CMyBView::OnMouseMove(UINT nFlags, CPoint point)
{
 // TODO: Add your message handler code here and/or call default
if (flags)
 {

   CDC *pDC=GetDC();

    CRect rect(startpoint.x, startpoint.y, temppoint.x, temppoint.y);

     rect.NormalizeRect();

     pDC->DrawFocusRect(rect);

    rect.SetRect(startpoint.x, startpoint.y, point.x, point.y);

   rect.NormalizeRect();

   pDC->DrawFocusRect(rect);

   temppoint=point;

   isrect=TRUE;
 
   ReleaseDC(pDC);

}

 

 
 CView::OnMouseMove(nFlags, point);
}

void CMyBView::OnLButtonUp(UINT nFlags, CPoint point)
{
 // TODO: Add your message handler code here and/or call default


   flags=FALSE;


 CView::OnLButtonUp(nFlags, point);

}

void CMyBView::OnRButtonUp(UINT nFlags, CPoint point)
{
 // TODO: Add your message handler code here and/or call default
   if(isrect)
   {

        CDC *pDC=GetDC();

        CRect rect(startpoint.x, startpoint.y, temppoint.x, temppoint.y);

         rect.NormalizeRect();

          pDC->DrawFocusRect(rect);

         ReleaseDC(pDC);

         isrect=FALSE;

}


 
 CView::OnRButtonUp(nFlags, point);
}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章