Drawing a continuous rectangle
- by JAYMIN
Hi..i m currently working on visual c++ 2008 express edition..
in my project i have a picturebox which contains an image, now i have to draw a rectangle to enaable the user to select a part of the image..
I have used the "MouseDown" event of the picturebox and the below code to draw a rectangle:
Void pictureBox1_MouseDown(System::Object^ sender, Windows::Forms::MouseEventArgs^ e)
{
Graphics^ g = pictureBox1-CreateGraphics();
Pen^ pen = gcnew Pen(Color::Blue);
g-DrawRectangle( pen , e-X ,e-Y,width,ht);
}
now in the "DrawRectangle" the arguments "width" and "ht" are static, so the above code results in the drawing of a rectangle at the point where the user presses the mouse button on the image in picturebox...
i want to allow the user to be able to drag the cursor and draw a rectangle of size that he wishes to..
Plz help me on this..
Thanx..