Well, I assume you've two points, say
{x0,y0}
(start-of-dragging point) and
{x1,y1}
end-of dragging point}. let's suppose
x0 != x1
and
y0 != y1
.
You should find the top-left point of the rectangle and the its size (both X and Y sizes):
int xtl, ytl;
int xbr, ybr;
int xcs, ycs;
if (x0 < x0)
{
xtl = x0; xbr = x1;
}
else
{
xtl = x1; xbr = x0;
}
if (y0 < y1)
{
ytl = y0; ybr = y1;
}
else
{
ytl = y1; ybr = y0;
}
xcs = xbr - xtl;
ycx = ybr - ytl;
Now you may properly create a rectangle, this way
Rectangle r(xtl, ytl, xcs, ycs);
:)