Image hover

speakers_86

Registered User.
Local time
Today, 11:02
Joined
May 17, 2007
Messages
1,919
When the mouse is over an image on a form, how can I get the mouse to show the hand, like if you hover over a link.
 
Here you go... I have no idea where it came from (maybe mvps.org/access?. It was in one of my project files.

Code:
'*********** Code Start  ************
' This code was originally written by Terry Kreft.
' It is not to be altered or distributed,
' except as part of an application.
' You are free to use it in any application,
' provided the copyright notice is left unchanged.
'
' Code Courtesy of
' Terry Kreft
'
Public Const IDC_APPSTARTING = 32650&
Public Const IDC_HAND = 32649&
Public Const IDC_ARROW = 32512&
Public Const IDC_CROSS = 32515&
Public Const IDC_IBEAM = 32513&
Public Const IDC_ICON = 32641&
Public Const IDC_NO = 32648&
Public Const IDC_SIZE = 32640&
Public Const IDC_SIZEALL = 32646&
Public Const IDC_SIZENESW = 32643&
Public Const IDC_SIZENS = 32645&
Public Const IDC_SIZENWSE = 32642&
Public Const IDC_SIZEWE = 32644&
Public Const IDC_UPARROW = 32516&
Public Const IDC_WAIT = 32514&

Declare Function LoadCursorBynum Lib "user32" Alias "LoadCursorA" _
  (ByVal hInstance As Long, ByVal lpCursorName As Long) As Long

Declare Function LoadCursorFromFile Lib "user32" Alias _
  "LoadCursorFromFileA" (ByVal lpFileName As String) As Long

Declare Function SetCursor Lib "user32" _
  (ByVal hCursor As Long) As Long

Function MouseCursor(CursorType As Long)
  Dim lngRet As Long
  lngRet = LoadCursorBynum(0&, CursorType)
  lngRet = SetCursor(lngRet)
End Function

Function PointM(strPathToCursor As String)
  Dim lngRet As Long
  lngRet = LoadCursorFromFile(strPathToCursor)
  lngRet = SetCursor(lngRet)
End Function
'*********** Code End ************
 
Thank you, but what event does that go in? And what do I change to refer to my image?
 
From the same project:

Code:
Private Sub Image11_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    MouseCursor (32649&)
End Sub

So it goes to the image's MouseMove event. I also believe you need form's (or in this case, a background image) MouseMove event to turn it back to pointer when it moves off the images.

Code:
Private Sub Image0_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    MouseCursor (32512&)
End Sub
 

Users who are viewing this thread

Back
Top Bottom