How to move rectangle with mouse
-
Hi all, I am drawing a rectangle using LineTo(HDC hdc,x,y). Now i planning to move or change the rectangle using mouse. For example:If i click the mouse on the rectangle line,then i can drag the rectangle line using mouse. Any idea will be helpful Thanks Raj
-
Hi all, I am drawing a rectangle using LineTo(HDC hdc,x,y). Now i planning to move or change the rectangle using mouse. For example:If i click the mouse on the rectangle line,then i can drag the rectangle line using mouse. Any idea will be helpful Thanks Raj
You need to capture the mouse co-ordinates as you drag and then use those values in your paint routine to redraw the rectangle either at a new position in your window or as a new size, depending on how your program is designed.
It's time for a new signature.
-
Hi all, I am drawing a rectangle using LineTo(HDC hdc,x,y). Now i planning to move or change the rectangle using mouse. For example:If i click the mouse on the rectangle line,then i can drag the rectangle line using mouse. Any idea will be helpful Thanks Raj
Firstly, you do not need to use
LineTo
to draw a rectangle. Use theRectangle
function instead. Secondly, you can achieve the same behavior using theCRectTracker
class if you're using MFC.«_Superman_»
I love work. It gives me something to do between weekends. -
Firstly, you do not need to use
LineTo
to draw a rectangle. Use theRectangle
function instead. Secondly, you can achieve the same behavior using theCRectTracker
class if you're using MFC.«_Superman_»
I love work. It gives me something to do between weekends.Hi, Thanks for your reply.The reason i used LineTo is. I have to draw to a rectangle and rotate with the given degree.I found it hard with Rectangle function. I am calculating the axis with the given degree and values first, and then drawing the lines with that axis to complete the rectangle. Now i want is : If i click the mouse on any of the line on rectangle.Mouse has to ba activated so that i can move the line and resize the rectangle.' I am confused ,how to start it. thanks Raj