RoundRect.cpp
上传用户:popouu88
上传日期:2013-02-11
资源大小:2894k
文件大小:1k
源码类别:

IP电话/视频会议

开发平台:

Visual C++

  1. // RoundRect.cpp: implementation of the CRoundRect class.
  2. //
  3. //////////////////////////////////////////////////////////////////////
  4. #include "stdafx.h"
  5. #include "RoundRect.h"
  6. #ifdef _DEBUG
  7. #undef THIS_FILE
  8. static char THIS_FILE[]=__FILE__;
  9. #define new DEBUG_NEW
  10. #endif
  11. //////////////////////////////////////////////////////////////////////
  12. // Construction/Destruction
  13. //////////////////////////////////////////////////////////////////////
  14. CRoundRect::CRoundRect( CDrawView * view ) : CDraw( view )
  15. {
  16. this->type = ROUNDRECT;
  17. }
  18. CRoundRect::~CRoundRect()
  19. {
  20. }
  21. void CRoundRect::MouseMove( UINT nFlags , CPoint point )
  22. {
  23. if( MK_LBUTTON & nFlags )
  24. {
  25. this->end = point;
  26. if( MK_SHIFT & nFlags )
  27. {   //计算最小的边
  28. int min = min( abs( this->end.x - this->start.x ) , abs( this->end.y - this->start.y ) );
  29. //计算最小的矩形
  30. this->end.x = this->start.x + ( this->end.x > this->start.x ? 1 : -1 ) * min;
  31. this->end.y = this->start.y + ( this->end.y > this->start.y ? 1 : -1 ) * min;
  32. }
  33. }
  34. CDraw::MouseMove( nFlags , point );
  35. }
  36. CDC * CRoundRect::Draw( CDC * pDC )
  37. {
  38. pDC = CDraw::Draw( pDC );
  39. if( pDC )
  40. {
  41. CRect rc( this->start , this->end );
  42. rc.NormalizeRect( );
  43. pDC->RoundRect( rc , CPoint( 15 , 15 ) );
  44. }
  45. return pDC;
  46. }