kiranreddys.com
Kiran's personal website
Blog    Forums   Sitemap   Social    Phone
 
     

 
Knowledgebase
 
Home
Knowledge base home, and site home.
Categories
List of all Knowledge base categories.
Glossary
An alphabetical list of technical terms.
Contact Me
Contact me for knowledge base questions
My Blog
My articles, white papers, ideas and thoughts.
 

 
 


Capture mouse enter and mouse leave events

Date Added January 1, 1970 | Print | Bookmark
'Code By Kiran.
'Capture mouse enter and mouse leave events
'As you know there is no mouse enter and mouse leave events in VB classic but you can get these by using following code and API but you have some limitation to use the code, control must have Hdc property; e.g.you can use it for PictureBox and CommandButton but not for Labels

'Windows API Declaration
Public Declare Function SetCapture Lib "user32" (ByVal hwnd As Long) As Long
Public Declare Function GetCapture Lib "user32" () As Long
Public Declare Function ReleaseCapture Lib "user32" () As Long

Private Sub Picturebox1_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)

With Picturebox1 'you control here, it must have hdc property
If ((x < 0) Or (x > .Width) Or (y < 0) Or (y > .Height)) Then 'MouseOut
Call ReleaseCapture
.BackColor = &H80FFFF 'you code her what ever you want to on mouse leave
ElseIf GetCapture <> .hwnd Then 'MouseEnter
Call SetCapture(.hwnd)
.BackColor = &HFF00& 'you code her what ever you want to on mouse over
Else
'Mouse Move
End If
End With
End Sub

Was this article helpful?

Yes No

Category: VB API

Last updated on January 1, 1970 with 6358 views

0 User Comments

There are no comments yet...Kick things off by filling out the form below.

Leave a Comment

CAPTCHA Image
Security code

 



Home | About Me | Products | Support | Contact | Knowledgebase | Forums | Blog | Site map | Site Search | Subscribe | Links | Social | News

Travel | Guest Book | All Pages | History | Site Calendar | Recipes | Ex-Rates | UK Stuff | Downloads | Telugu Stuff | Tell a Friend | Feedback

Bookmark and Share
www.kiranreddys.com
Terms of Use
Site contents Copyright © 2008-2009 Kiran Reddy. All rights reserved.