TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
t800 t8
NA
1
0
Hit testing problem
Dec 15 2005 9:38 PM
I need to write a program which can draw rectangle by mouse. User can draw a rectangle by click left mouse button and drag mouse, when user release left mouse button, rectangle will be drawn. Now I can draw rectangle, but I want to check when I move mouse, program can show me the mouse is inside a rectangle or not. I use an RectangleArray which inherits from CollectionBase to store all drawn rectangle. In mose move method, I loop through this array and use Contains method of Rectangle class to check the mouse inside or not. But I don't understand while I only can check the position of mouse if it is inside the first rectangle I drawn (label4 does not change value). But if I show a message box, label4 can change its value. private void picImage_MouseMove(object sender, MouseEventArgs e) { Point mousePoint = new Point(e.X, e.Y); foreach (Rectangle rect in rects) { if (rect .Contains(mousePoint)) { label4.Text = "In rect"; //MessageBox.Show(mouseIsInShelf.ToString()); break; } else { label4.Text = "Not in rect"; } } } Can anybody help me? Thanks a lot!
Reply
Answers (
0
)
Enable/Disable all the server controls on a C# webform
How Post from C#?