Solved

MouseMove Event

Posted on 1998-08-11
2
150 Views
Last Modified: 2010-04-30
I've got a series of buttons on a form.  I want the buttons BackColor proprty to change from default gray to red when the user's mouse moves over the button.  The buttons' Style is set to Graphical.  I know how to make the button change colors once, but not change back to default gray when its NOT selected.
Private Sub cmdButton1_MouseMove(Button As Integer, Shift

As Integer, X As Single, Y As Single)
cmdButton1.BackColor = &HC0FFFF

End Sub

Changes the background color of the button when the mouse is over it.  Anyone got an idea?

BTW - The buttons are NOT in an array.  They are all named separately (for a reason).
Thanks..
0
Comment
Question by:EvanL
2 Comments
 
LVL 1

Accepted Solution

by:
jsuper earned 60 total points
ID: 1468557
Well,  It will talk a bit of coding, but I would use the object_mousemove events for all of the OTHER controls on he form as well as the form.   If the mouse is being moved over any other objects, then you know the mouse is not ove rany of the command buttons.  For example, let's say the only ojbects on the form are the command buttons.   Then I would add the following event code...

Private Sub Form1_MouseMove(Button As Integer, Shift   As Integer, X As Single, Y As Single)
   cmdButton1.BackColor =   (Original Color)
   cmdButton2.BackColor =   (Original Color)
End Sub

If there are any other controls on the form, Add the same code to those events.   In fact, I would probably create a Reset_Color subroutine and just call the subroutine in each event.  I must admit,  I haven't tried this, but it should work in theory...
0
 
LVL 1

Author Comment

by:EvanL
ID: 1468558
not sure why I couldn't think of this..  no caffeine this AM..

thanks for the answer..  quite easy..

word to anyone "buying" this question.. It is much faster to highlight a command button using a font property (fontitalic, fontunderline, fontbold) than to make the button change colors..

best..
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now