APD Toronto
asked on
Mouse Hover
Hi Experts
Using VBA in PowerPoint, how can I achieve a Mouse Hover effect, so when the user moves the mouse over a button it changes color, then when it moves it out it changes another color? Is this the MouseDown event, using the X & Y values?
Also, colors such as &H00FFFFFF& - are these hexadecimal? If no, can they be or RGB?
Thank you.
Using VBA in PowerPoint, how can I achieve a Mouse Hover effect, so when the user moves the mouse over a button it changes color, then when it moves it out it changes another color? Is this the MouseDown event, using the X & Y values?
Also, colors such as &H00FFFFFF& - are these hexadecimal? If no, can they be or RGB?
Thank you.
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
Sorry, should've used ForeColor, which works. However, what about reversing it back on MouseOut
ASKER
@James, there will be only 4 lines of code if I use MouseMove, and there are Top and Left properties of the object. Isn't MouseMove viable?
Yes, you could always try it, but it will be more than 4 lines of code.
The thing is that you cannot know from which side the user will be entering. Same thing for the exit.
And you cannot simply check for the values of 0, button width and button height to determine if the cursor is on a border. I cannot say for Office, because I never had to use MouseMove with Office, but in other environments, MouseMove trigger on a timer instead of on the pixels. Many pixels can be skipped between 2 MouseMoves, so the first MouseMove for a cursor entering the control top might be at 1, 2 or 4, maybe more. You would have to test to see the amount of pixels you should consider around the control.
It will also be hard, to determine when the user is getting out, many situations will have to be considered.
Say that the user enter from the Left on a MouseMove at 4, then suddenly moves back out of the control. You will get only the Enter and will not be able to detect the exit. You need at least 2 MouseMove in order to detect both entry and exit.
Then, think of a user that moves horizontally very close to the top. You will get a series of Top positions that could oscillate between, let's say, 2 and 4 because the user is just a bit shaky. How will you know, in the sequence 2233432342, that the last 2 is the one getting you out of the control?
In my opinion, doing it with the MouseMove can work most of the time if properly done, but there will be many situations in which you won't be able to detect the mouse getting out.
For a user, nothing is annoying as erratic behavior.
One idea that I have while writing this. Playing with events often asks for creative ways to fix things.
Behind your Button, put a Label that is larger than the Button and make it the same color as the background, so that it does not show. When the user gets out of the Button, the Label will start receiving MouseMove. This is your indication that the cursor is out and that the Button should get back to normal.
The thing is that you cannot know from which side the user will be entering. Same thing for the exit.
And you cannot simply check for the values of 0, button width and button height to determine if the cursor is on a border. I cannot say for Office, because I never had to use MouseMove with Office, but in other environments, MouseMove trigger on a timer instead of on the pixels. Many pixels can be skipped between 2 MouseMoves, so the first MouseMove for a cursor entering the control top might be at 1, 2 or 4, maybe more. You would have to test to see the amount of pixels you should consider around the control.
It will also be hard, to determine when the user is getting out, many situations will have to be considered.
Say that the user enter from the Left on a MouseMove at 4, then suddenly moves back out of the control. You will get only the Enter and will not be able to detect the exit. You need at least 2 MouseMove in order to detect both entry and exit.
Then, think of a user that moves horizontally very close to the top. You will get a series of Top positions that could oscillate between, let's say, 2 and 4 because the user is just a bit shaky. How will you know, in the sequence 2233432342, that the last 2 is the one getting you out of the control?
In my opinion, doing it with the MouseMove can work most of the time if properly done, but there will be many situations in which you won't be able to detect the mouse getting out.
For a user, nothing is annoying as erratic behavior.
One idea that I have while writing this. Playing with events often asks for creative ways to fix things.
Behind your Button, put a Label that is larger than the Button and make it the same color as the background, so that it does not show. When the user gets out of the Button, the Label will start receiving MouseMove. This is your indication that the cursor is out and that the Button should get back to normal.
ASKER
Expanding on your code, I'm trying the folowing, but nothing is happening
Open in new window