How to give mouse event on rectangle and resize
-
Hi all, I am drawing one rectangle with some given values and degree. Now i want to give the mouse event if i click the mouse on that rectangle,it should be activated so that i can drag it and resize. The code i am using to draw rectangle is:
LPTSTR lpsz;
ColliAngle = "45";
int ang;ang = _ttoi(ColliAngle);
float Angle = ( 3.142 * ang ) / 180;
int x[4];
int y[4];
x[0] = -x1 * cos(Angle) - y2 * sin(Angle);
y[0] = x1 * sin(Angle) - y2 * cos(Angle);
x[1] = -x1 * cos(Angle) + y1 * sin(Angle);
y[1] = x1 * sin(Angle) + y1 * cos(Angle);
x[2] = x2 * cos(Angle) + y1 * sin(Angle);
y[2] = -x2 * sin(Angle) + y1 * cos(Angle);
x[3] = x2 * cos(Angle) - y2 * sin(Angle);
y[3] = -x2 * sin(Angle) - y2 * cos(Angle);
for (int i=0; i<4; i++)
{
x[i] += center.x;
y[i] += center.y;
}
MoveToEx(pCellInfo->hDC,x[3],y[3],NULL);
for (int i=0; i<4; i++)
{LineTo(pCellInfo->hDC, x\[i\],y\[i\]);
}
Please help me i dont know how to start and totally hanged. Thanks Raj
-
Hi all, I am drawing one rectangle with some given values and degree. Now i want to give the mouse event if i click the mouse on that rectangle,it should be activated so that i can drag it and resize. The code i am using to draw rectangle is:
LPTSTR lpsz;
ColliAngle = "45";
int ang;ang = _ttoi(ColliAngle);
float Angle = ( 3.142 * ang ) / 180;
int x[4];
int y[4];
x[0] = -x1 * cos(Angle) - y2 * sin(Angle);
y[0] = x1 * sin(Angle) - y2 * cos(Angle);
x[1] = -x1 * cos(Angle) + y1 * sin(Angle);
y[1] = x1 * sin(Angle) + y1 * cos(Angle);
x[2] = x2 * cos(Angle) + y1 * sin(Angle);
y[2] = -x2 * sin(Angle) + y1 * cos(Angle);
x[3] = x2 * cos(Angle) - y2 * sin(Angle);
y[3] = -x2 * sin(Angle) - y2 * cos(Angle);
for (int i=0; i<4; i++)
{
x[i] += center.x;
y[i] += center.y;
}
MoveToEx(pCellInfo->hDC,x[3],y[3],NULL);
for (int i=0; i<4; i++)
{LineTo(pCellInfo->hDC, x\[i\],y\[i\]);
}
Please help me i dont know how to start and totally hanged. Thanks Raj
To identify if the mouse is clicked on the line use the
LineDDA
function. This function calls a callback function with each point on the line. Compare this will the point where the mouse was clicked.«_Superman_»
I love work. It gives me something to do between weekends. -
Hi all, I am drawing one rectangle with some given values and degree. Now i want to give the mouse event if i click the mouse on that rectangle,it should be activated so that i can drag it and resize. The code i am using to draw rectangle is:
LPTSTR lpsz;
ColliAngle = "45";
int ang;ang = _ttoi(ColliAngle);
float Angle = ( 3.142 * ang ) / 180;
int x[4];
int y[4];
x[0] = -x1 * cos(Angle) - y2 * sin(Angle);
y[0] = x1 * sin(Angle) - y2 * cos(Angle);
x[1] = -x1 * cos(Angle) + y1 * sin(Angle);
y[1] = x1 * sin(Angle) + y1 * cos(Angle);
x[2] = x2 * cos(Angle) + y1 * sin(Angle);
y[2] = -x2 * sin(Angle) + y1 * cos(Angle);
x[3] = x2 * cos(Angle) - y2 * sin(Angle);
y[3] = -x2 * sin(Angle) - y2 * cos(Angle);
for (int i=0; i<4; i++)
{
x[i] += center.x;
y[i] += center.y;
}
MoveToEx(pCellInfo->hDC,x[3],y[3],NULL);
for (int i=0; i<4; i++)
{LineTo(pCellInfo->hDC, x\[i\],y\[i\]);
}
Please help me i dont know how to start and totally hanged. Thanks Raj