Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default RollOver buttons in UserForms (A solution)

What about using the mousemove event of the userform
itself to reset the colours?

Leyton

-----Original Message-----
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


.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default RollOver buttons in UserForms (A solution)

Yes it is a solution that I used before but then you have to code it in each
of the forms and if the buttons are positionned on top of an image or any
kind of other control, you'll have to put the code in that control too. And
if the buttons are standing side by side, touching each other, you need a
way to reset the colors when your mouse slides from one button to the other,
furthermore, if the adjacent button is disabled, moving over it wont trigger
it's MouseMove event.

Thanks for the hint.

Pierre
--------------------------------------

"Leyton" a écrit dans le message de
...
What about using the mousemove event of the userform
itself to reset the colours?

Leyton

-----Original Message-----
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


.



Reply
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 01:07 AM.

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

About Us

"It's about Microsoft Excel"