Home > Visual C++ > Center point of a Rectangle !!

Center point of a Rectangle !!

November 27, 2008 BijU Leave a comment Go to comments

 

Do you know how to calculate the center of a rectangle?

using simple maths and by knowing the coordinates of a rectangle, you can. :)

Before those calculation, just try the MFC method of CRect class. 

CRect::CenterPoint()

which returns a CPoint object that is the centerpoint of CRect.

for example

CRect rect;
GetWindowRect(&rect);
CPoint cPoint;
cPoint = rect.CenterPoint();

//cPoint.x will returns the Center x coordinate and cPoint.y returns the Center y coordinate

Keep doing your part and leave the rest to God.

 

for http://vctipsplusplus.wordpress.com/

BijU

 

:)

Categories: Visual C++
  1. No comments yet.
  1. No trackbacks yet.