by Nathanael B (3 Submissions)
Category: Windows API Call/Explanation
Compatability: Visual Basic 5.0
Difficulty: Intermediate
Date Added: Wed 3rd February 2021
Rating: (11 Votes)
This small piece of code will set the cursor to the hand cursor that is shown when you hover above a hyperlink. I know you can use a .RES file to load the cursor, but the cursor can be changed in the Mouse control panel, and a .RES cursor will not reflect the changes. NOTE: This is not all my code. I found the API call on VBC (had to do quite a bit of searching), and put together a little Subroutine to make it easier to do. The original source is here: https://www.vbcoders.com/vb/scripts/ShowCode.asp?txtCodeId=31572&lngWId=1
Inputs
True/False value. If Hand=True, the hyperlink cursor will be displayed, if it is False, the standard pointer will be displayed.
API DeclarationsPublic Declare Function LoadCursor Lib "user32" Alias "LoadCursorA" (ByVal hInstance As Long, ByVal lpCursorName As Long) As Long
Public Declare Function SetCursor Lib "user32" (ByVal hCursor As Long) As Long
Public Const IDC_HAND = 32649&
Public Const IDC_ARROW = 32512&
Public Sub SetHandCur(Hand As Boolean)
If Hand = True Then
SetCursor LoadCursor(0, IDC_HAND)
Else
SetCursor LoadCursor(0, IDC_ARROW)
End If
End Sub