Drawing a continuous rectangle
Posted
by JAYMIN
on Stack Overflow
See other posts from Stack Overflow
or by JAYMIN
Published on 2010-03-19T06:19:37Z
Indexed on
2010/03/19
6:21 UTC
Read the original article
Hit count: 327
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..
© Stack Overflow or respective owner