mouseover events

mojo
09-07-2000, 05:27 AM
How do I get a command button to change it's properties (eg change to red) on mouseover?

Derek Stone
09-07-2000, 06:12 AM
Do you want the forecolor to change or do you want the backcolor to change?
If it is the backcolor it is easy.
Change the Style of the button to graphical and in its mousemove event type Command1.BackColor = vbBlue.
Make sure to change "Command1" to th name of your button and "vbBlue" to the color you want.
If it is the forecolor you want to change then it is farely complicated.
It is easier to use a premade OCX then code it yourself.
Go to: <A HREF="http://www.planet-source-code.com/vb" target="_new">http://www.planet-source-code.com/vb</A> and search for Gold Button.
It is a very good OCX for stylish command buttons.
Good Luck

-cl

mojo
09-07-2000, 07:06 AM
thanks crazed... I got the backcolor to change by using mousemove. But...how do I get it to revert to grey when the mouse is moved off the button? (ie I only want the change of colour while the mouse is on the button). Thanks, Mojo

CornMaster
09-07-2000, 09:16 AM
I'll post the code that I used.

Private Sub Command1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Command1.BackColor = &HFF0000 'This means blue
End Sub

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Command1.BackColor = &HC0C0C0 'This means Grey
End Sub

It should work perfectly.
Just remember to set the button to graphical.


CornEmpire Board Administrator
<A HREF="http://www.geocities.com/thecornmaster/" target="_new">http://www.geocities.com/thecornmaster/</A>

BillSoo
09-07-2000, 12:51 PM
I used to do it this way too but occasionally, someone would move the mouse too fast and be over another control before the form mousemove event could fire. So I put all the code in a timer firing every 20ms. It's fairly big since it has routines for all controls on the form but the upside is that at least it's all in one place!

"I have a plan so cunning you could put a tail on it and call it a weasel!" - Edmund Blackadder

mojo
09-11-2000, 02:32 AM
Thanks CornMaster

worked perfectly...just like you said.

If the user moves so fast that it doesn't have time to fire...then it would appear they were never intending to use that control anyway.

CornMaster
09-11-2000, 12:37 PM
Your welcome. Hey I helped someone!!
You can also use mouseover for other things as well. I personally use it for giving descriptions of buttons that lead to other programs.
I would put a Label and in the mousemove on the button set the Label1.Caption = "Program Description"
This is very similar to using drop down tool tips in other windows programs. Anyway maybe it will give you more ideas!!

CornEmpire Board Administrator
<A HREF="http://www.geocities.com/thecornmaster/" target="_new">http://www.geocities.com/thecornmaster/</A>

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum