sign in | join about | help | sitemap
Connecting Tech Pros Worldwide
john ciriello's Avatar

Detect mouse enter when button disabled


Question posted by: john ciriello (Guest) on August 19th, 2008 12:25 PM
Hi, is there an easy way to detect when the mouse pointer enters a disabled
button? For example I have a button I can see but it is greyed out. When the
mouse moves over it I would like to be able to right click and have it
respond with a context menu. Any ideas? Thanks in advance.



3 Answers Posted
Frank Werner-Krippendorf's Avatar
Frank Werner-Krippendorf August 19th, 2008 04:35 PM
Guest - n/a Posts
#2: Re: Detect mouse enter when button disabled

Hello John,

you could place your code in the container's 'MouseMove' event handler:


private void Form1_MouseMove(object sender, MouseEventArgs e)
{

if ((e.X >= yourButton.Left && e.X <= yourButton.Right) &&
(e.Y >= yourButton.Top && e.Y <= yourButton.Bottom))
{
MessageBox.Show("?");
}


}


Frank Werner-Krippendorf


Quote:
Originally Posted by
Hi, is there an easy way to detect when the mouse pointer enters a
disabled button? For example I have a button I can see but it is
greyed out. When the mouse moves over it I would like to be able to
right click and have it respond with a context menu. Any ideas? Thanks
in advance.
>



Duggi's Avatar
Guest - n/a Posts
#3: Re: Detect mouse enter when button disabled

On Aug 19, 8:26*pm, Frank Werner-Krippendorf <Frank.werner-
krippend...@franke.comwrote:
Quote:
Originally Posted by
Hello John,
>
you could place your code in the container's 'MouseMove' event handler:
>
*private void Form1_MouseMove(object sender, MouseEventArgs e)
* * * * {
>
* * * * * * if ((e.X >= yourButton.Left && e.X <= yourButton.Right) &&
* * * * * * * * (e.Y >= yourButton.Top && e.Y <= yourButton.Bottom))
* * * * * * {
* * * * * * * * MessageBox.Show("?");
* * * * * * }
>
* * * * }
>
Frank Werner-Krippendorf
>
Quote:
Originally Posted by
Hi, is there an easy way to detect when the mouse pointer enters a
disabled button? For example I have a button I can see but it is
greyed out. When the mouse moves over it I would like to be able to
right click and have it respond with a context menu. Any ideas? Thanks
in advance.


I think thats excellent idea... Let me see if that works out...

-Cnu
Duggi's Avatar
Guest - n/a Posts
#4: Re: Detect mouse enter when button disabled

On Aug 19, 8:26*pm, Frank Werner-Krippendorf <Frank.werner-
krippend...@franke.comwrote:
Quote:
Originally Posted by
Hello John,
>
you could place your code in the container's 'MouseMove' event handler:
>
*private void Form1_MouseMove(object sender, MouseEventArgs e)
* * * * {
>
* * * * * * if ((e.X >= yourButton.Left && e.X <= yourButton.Right) &&
* * * * * * * * (e.Y >= yourButton.Top && e.Y <= yourButton.Bottom))
* * * * * * {
* * * * * * * * MessageBox.Show("?");
* * * * * * }
>
* * * * }
>
Frank Werner-Krippendorf
>
Quote:
Originally Posted by
Hi, is there an easy way to detect when the mouse pointer enters a
disabled button? For example I have a button I can see but it is
greyed out. When the mouse moves over it I would like to be able to
right click and have it respond with a context menu. Any ideas? Thanks
in advance.


This works out cooool....

-Cnu
 
Not the answer you were looking for? Post your question . . .
196,977 members ready to help you find a solution.
Join Bytes.com

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 196,977 network members.
Post your question now . . .
It's fast and it's free

Popular Articles

Top Community Contributors