473,382 Members | 1,147 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Draw rectangle on picturebox (moving with mouse)

Hello

I've written some code to draw a rectangle on a picture box when the user moves the mouse.
(the previous rectangle is cleared)
This works fine but the very first rectangle is not removed from the screen.

here is my code

[PHP]
private Rectangle r = new Rectangle(new Point(0,0), new Size(0,0));

private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
{
Point startPoint = ((Control)sender).PointToScreen(new Point(e.X, e.Y));


ControlPaint.DrawReversibleFrame(r, this.BackColor, FrameStyle.Dashed);

r = new Rectangle(startPoint.X, startPoint.Y, 100, 200);
ControlPaint.DrawReversibleFrame(r, this.BackColor, FrameStyle.Dashed);
}
[/PHP]
Feb 27 '08 #1
0 2299

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Steve | last post by:
I'm using CustomDraw to draw my listview item but there seems to be some basic characteristics of the draw operation that Windows refuses to allow you to change. 1) I want to most the position of...
1
by: Robert W. | last post by:
In my Winforms app I'm trying to get an image's background to appear transparent on a form that has a gradient background. So I added a PictureBox and then attempted to add a custom paint command...
6
by: Brad Shook | last post by:
Can someone point me to an example or post some code on how to allow a user to draw a rectangle on top of an image and retrieve the coordinates and dimensions of it. They will also need to be able...
3
by: b747_440 | last post by:
Hello Newsgroup, I try to resize and move a picturebox. However, after each operation the picture box is being redrawn. This causes flickering. Is it possible to suppress the first redraw and draw...
1
by: nicolus | last post by:
my problem is to draw a rectangle shape on the picturebox at execution time for that i wrote code which is working well in one project later i just copied that code to the project where i actually...
1
by: Jeff Waskiewicz | last post by:
Hello All, I'm trying to solve a nagging problem. The goal is to draw a rectangle over the top of all the other controls on a form. Specifically, over a ChartFX control. The user would draw...
0
by: Ben3eeE | last post by:
Im having trouble making a Paint.exe straight line draw. You know the one where you point out where to start then hold down the mouse button and release it to finish the drawing. My problem is...
10
by: kimiraikkonen | last post by:
Hi, If previous post was missing, here's the complete one: I'm trying to draw a rectange on a picturebox image using mouse move event but the problem is that the rectangle selection / drawing...
1
by: kummu4help | last post by:
hi, i want to draw rectangle based on mousedrag event. if user dragging the mouse, then the rectangle on the applet should increase or decrease basing on current mouse coordinates. i have the...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.