Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Vacation accrual based on years with rollover | Excel Worksheet Functions | |||
rollover number help | Excel Discussion (Misc queries) | |||
Mouse rollover pop-up message | Excel Worksheet Functions | |||
Graphic Images: Can I Put One in a Cell as Mouse Rollover Only? | Excel Discussion (Misc queries) | |||
Excel Project rollover for 2006 | Excel Worksheet Functions |