| View previous topic :: View next topic |
| Author |
Message |
Avis Junior Poster

Joined: 07 Oct 2003 Posts: 510 Location: India
|
Posted: Nov 3rd, 2003 06:02 AM Post subject: MouseOver Effect on Command Buttons |
|
|
This is my example for a mouseover effect for buttons... edit it accordingly :p ... this will change the forecolor property from grey to white on mouseover
| Code: | Private Declare Function ReleaseCapture Lib "USER32" () As Long
Private Declare Function SetCapture Lib "USER32" (ByVal hwnd As Long) As Long
Private Sub Command1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
' will change the background color for the command button
With Command1
If (X < 0) Or (Y < 0) Or (X > .Width) Or (Y > .Height) Then
ReleaseCapture
Command1.BackColor = &HE0E0E0
Else
SetCapture .hwnd
Command1.BackColor = vbWhite
End If
End With
End Sub |
Remember to set the command1's style property to graphical. This is rather helpful instead of using a control to do basically the samething. You can also use the same code in MouseDown event to get some other color when button is clicked. _________________ Code Snippets, Tutorials, Utilities, Controls
Low cost Web Hosting
Hosting starts at as low as $4 per year!
Always follow posting guidelines
Put your VB code in [vb ] your code [ /vb] tags! |
|
| Back to top |
|
P.T.A.M. Administrator

Joined: 08 Oct 2003 Posts: 752 Location: Greece
|
Posted: Nov 4th, 2003 12:56 AM Post subject: |
|
|
The drawback with this is that you need an hwnd property for the control. You can't use this with a label... Here are some other examples that don't have the same requirements (MouseMove, hwnd) http://www.avissoft.com/showthread.php?s=&threadid=6 _________________ No one is completely useless. They can at least be an example of what to avoid.
Last edited by P.T.A.M. on Nov 4th, 2003 12:59 AM; edited 1 time in total |
|
| Back to top |
|
VBMaster Newbie
Joined: 02 Feb 2004 Posts: 5
|
Posted: Feb 3rd, 2004 12:03 PM Post subject: |
|
|
This is a very uniqe code, Never seen this, I think I'll try it, but one question. Is this code involving use VB 5.0 or 6.0 or the enterprise. Don't know what enterprise is maybe there is'nt one. O well. _________________ VB is like teaching a computer to do things...why can't it be that simple for humans.
Richard |
|
| Back to top |
|
Avis Junior Poster

Joined: 07 Oct 2003 Posts: 510 Location: India
|
|
| Back to top |
|
|