473,769 Members | 6,286 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

[C#]: MouseMove & Scroll

1 New Member
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_Mouse Move(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 3922
Shashi Sadasivan
1,435 Recognized Expert Top Contributor
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_Mouse Move(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
1994
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 want the objects (colored divs) to scroll with the mouse in Opera 6. I give the mouse y coords (-) window.pageYOffset and the objects (+) window.pageYOffset. However, in Opera 7 it doesn't work. Only the following objects need (+)...
5
3520
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 scrolling to NO shouldn't it sitll appear w/no scroll bars?? thank you.. Frances Del Rio
5
5234
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
6019
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 VScrollbar. I can't set the "AutoScroll"-property to true and then use the generated scrollbars inside the panel, because i have to use this external scrollbar which is a modified/customized scrollbar, and doesn't look like a standard scrollbar.
3
5669
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 spurious MouseMove events when the cursor doesn't actually move. I've looked for a solution in the groups, and although I've come close, I haven't found a proper explanation or fix. Here is a rundown, followed by a very simple test app that...
3
5157
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 below) as one would expect from a screen saver. Well my Click event fires but for some reason my MouseMove event does not. Both the Form and the PictureBox are enabled. In my Form_Load routine, I tried placing "Me.Capture = true" which...
0
43812
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 use to some of you. The MouseMove Event is used to trigger an action when the user moves the mouse cursor over an object such as a textbox, label or command button. This can be applied to a number of routines. The attached zip file,...
0
9587
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10211
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9993
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9863
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8870
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7406
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5298
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5447
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.