Log inUsernamePassword
Log me on automatically each visit    
Register
Register
Log in to check your private messages
Log in to check your private messages
Visual Basic Forum for Visual Basic Programmers VB Forum Index » Knowledge Base

Post new topic   Reply to topic
MouseOver Effect on Command Buttons
View previous topic :: View next topic  
Author Message
Avis
Junior Poster


Joined: 07 Oct 2003
Posts: 510
Location: India

PostPosted: Nov 3rd, 2003 06:02 AM    Post subject: MouseOver Effect on Command Buttons Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger ICQ Number
P.T.A.M.
Administrator


Joined: 08 Oct 2003
Posts: 752
Location: Greece

PostPosted: Nov 4th, 2003 12:56 AM    Post subject: Reply with quote

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) Smile 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
View user's profile Send private message Send e-mail Visit poster's website ICQ Number
VBMaster
Newbie


Joined: 02 Feb 2004
Posts: 5

PostPosted: Feb 3rd, 2004 12:03 PM    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
Avis
Junior Poster


Joined: 07 Oct 2003
Posts: 510
Location: India

PostPosted: Feb 3rd, 2004 01:44 PM    Post subject: Reply with quote

Hi!

This code can be used with VB 5.0 and VB 6.0 but not with the CCE. Rest is supported. Enterprise and Professional are supported.

Thanks!
_________________
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
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger ICQ Number
Display posts from previous:   
Post new topic   Reply to topic    Visual Basic Forum for Visual Basic Programmers VB Forum Index » Knowledge Base All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Visual Basic Forum runs phpBB | Forum Template © iOptional
VB Resources | SSL | Visual Basic