LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default RollOver buttons in UserForms (A solution)

Hi,

Last week I posted a message about creating a weblike "RollOver" on all
buttons in all the userforms contained in a VBA project. Nobody paid
attention except for Tom Ogilvy who suggested to look at John Walkenbach's
code for a technique to provide one
event for multiple controls.

At that time I already had some partially working code and I slept on my
little problem (just nice to have) for the rest of the week. Today I am
proud to say that I have found a way to do the job. It's short and sweet.

In the MouseMove event of each CommandButton of every UserForm, place this
piece of code:
---------------------------------------------------
Private Sub CmdOk_MouseMove(ByVal Button As Integer, ByVal Shift As Integer,
ByVal X As Single, ByVal Y As Single)

Dim MyButton As Control

Set MyButton = CmdOk '(Here you will have to use the name of the
current button)
Call RollOver(MyButton, X, Y)

End Sub
----------------------------------------------------

Then create this RollOver Sub in a Module
----------------------------------------------------
Public Sub RollOver(Button As Control, X As Single, Y As Single)

If X 6 And X < Button.Width - 7 And Y 4 And Y < Button.Height - 5 Then
Button.ForeColor = vbWhite
Button.BackColor = &HC00000 'Dark blue
Else
Button.ForeColor = vbBlack
Button.BackColor = &HC0C0C0 'My default colors
End If

End Sub
-----------------------------------------------------

The RollOver Sub tests for a peripheral zone all around and inside the
button. If the mouse enters that zone, the colors are set to the original
settings but if it continues further inside, the colors are changed to
whatever color you want. And when the mouse moves away from the button, it
passes over the surrounding "reset" zone again.

Neat isn't it. But there is a hitch... The mouse does'nt seem to trigger
the MouseMove event fast enough when it passes over the "reset" zone so that
it often fails to reset the colors. I tried to reduce the mouse pointer
acceleration and it's speed (in the control pannel) but that does'nt change
the results.

So if somebody has an idea, please let me know.

Pierre


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Vacation accrual based on years with rollover jdcinama Excel Worksheet Functions 1 September 25th 09 10:11 PM
rollover number help Nathanael Excel Discussion (Misc queries) 2 January 22nd 09 01:40 PM
Mouse rollover pop-up message rhemingway Excel Worksheet Functions 6 March 11th 08 03:50 PM
Graphic Images: Can I Put One in a Cell as Mouse Rollover Only? J. Danniel Excel Discussion (Misc queries) 4 August 10th 07 07:19 AM
Excel Project rollover for 2006 P. Hayes Excel Worksheet Functions 0 January 5th 06 08:27 PM


All times are GMT +1. The time now is 08:08 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"