473,396 Members | 2,151 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,396 software developers and data experts.

[C#]: MouseMove & Scroll

1
Hello everybody!
I've a problem with MouseMove event in a C# project using Visual Studio 2005.
This is my situation: there is a PictureBox (bigger than the panel in which it is) and I want that, when the user moves his mouse over some sensible areas (that are other invisible small PictureBox), the cursor has to become a hand.

In order to realize it, I wrote this code:

private void stradario_MouseMove(object sender, MouseEventArgs e)
{
int i;
bool Manina = false;
if ((e.X >= vertice[i].Location.X) && (e.X <= vertice[i].Location.X + 15) && (e.Y >= vertice[i].Location.Y) && (e.Y <= vertice[i].Location.Y + 15))
for (i = 0; i < 150; i++)
{
if (areaSensibile(vertice[i], e))
Manina = true;
}
if (Manina)
Cursor = Cursors.Hand;
else
Cursor = Cursors.Default;
}

But there is a problem: it works only if I don't scroll the picturebox! In facts, the cursor becomes a hand over the sensible areas that are situated in the top of the big PictureBox, but it doesn't do anything if I scroll the picturebox and I move my mouse over the areas in the bottom!

Any suggestion?
Oct 20 '07 #1
1 3898
Shashi Sadasivan
1,435 Expert 1GB
Hello everybody!
I've a problem with MouseMove event in a C# project using Visual Studio 2005.
This is my situation: there is a PictureBox (bigger than the panel in which it is) and I want that, when the user moves his mouse over some sensible areas (that are other invisible small PictureBox), the cursor has to become a hand.

In order to realize it, I wrote this code:

private void stradario_MouseMove(object sender, MouseEventArgs e)
{
int i;
bool Manina = false;
if ((e.X >= vertice[i].Location.X) && (e.X <= vertice[i].Location.X + 15) && (e.Y >= vertice[i].Location.Y) && (e.Y <= vertice[i].Location.Y + 15))
for (i = 0; i < 150; i++)
{
if (areaSensibile(vertice[i], e))
Manina = true;
}
if (Manina)
Cursor = Cursors.Hand;
else
Cursor = Cursors.Default;
}

But there is a problem: it works only if I don't scroll the picturebox! In facts, the cursor becomes a hand over the sensible areas that are situated in the top of the big PictureBox, but it doesn't do anything if I scroll the picturebox and I move my mouse over the areas in the bottom!

Any suggestion?
Why have you got those location conditions for.
Probably set them just for the controls you want to set the cursor for...and use the mouse events on them
Oct 21 '07 #2

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

Similar topics

7
by: Pete | last post by:
I'm working (playing) on a mouse following script. Yes, the sort no one likes but I'm having great fun tinkering with it - sad. Anyway, if there's enough page content to cause scrolling and I...
5
by: Frances Del Rio | last post by:
why do I keep getting scroll bars on frames even though I have scrolling set to "no"?? (am on IE..) I mean even if you put an img in there or sthg that's a bit larger than the frame if you set...
5
by: Jazzis | last post by:
Does anybody know if it's possible to change the color of the SELECT scroll bar using CSS, similar to changing the document scroll bar color using scrollbar-base-color attribute? Adam
2
by: Sascha Schmidt | last post by:
Hello ! I'm trying to combine an external (not part of the panel) vertical scrollbar (VScrollBar) with a panel in order to scroll the content of the panel vertically using the external ...
3
by: Crucifix | last post by:
Hello, I'm writing a small C# app, and part of what I'm trying to do involves the dragging of PictureBox controls on a form. Unfortunately, MouseMove seems to be behaving very oddly, causing...
3
by: TyBreaker | last post by:
I'm writing a screen saver using Visual Studio 2005 (Basic) and I have a Form which contains a PictureBox. I have two events, Click and MouseMove that I'd like to cause the program to end (see...
0
missinglinq
by: missinglinq | last post by:
Having been asked, for the umpteenth time, how to use the MouseMove property to change the appearance of an object, I put together this short tutorial and sample database today. Perhaps it will be of...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.