ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Hand cursor/icon like with Internet Explorer hyperlink (https://www.excelbanter.com/excel-programming/328543-hand-cursor-icon-like-internet-explorer-hyperlink.html)

Paul Martin

Hand cursor/icon like with Internet Explorer hyperlink
 
Hi all

I have found an alternative solution to the problem of a suitable
cursor to emulate a hyperlink. I have a label with a Click event, and
I want the cursor to look like the hand over a hyperlink in Internet
Explorer.

I've tried the hyperlink cursor solution provided by John Walkenbach
and others, but I don't really like the cursor image (nor have I been
able to find one I like).

I found another solution on Google that others might find useful,
because the cursor appears to be the IE cursor.
The first block of code goes into a module:

Public 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
__________________________________________________ _______

Then, on the UserForm for the label (or relevant control) MouseMove
and MouseDown events:

SetHandCur True

When the cursor is over the control, the cursor changes, and using the
MouseDown event ensures that the cursor does not revert to default
when clicking a mouse button.

Regards

Paul Martin
Melbourne, Australia

[email protected]

Hand cursor/icon like with Internet Explorer hyperlink
 
PS The original posting may be found at:
<http://groups.google.com.au/group/microsoft.public.vb.syntax/msg/7675b4d391cc386c?hl=en

I have modified the code as follows:

Public Sub SetHandCursor(bUseHandA As Boolean)
Dim lCursor As Long

lCursor = IIf(bUseHandA = True, IDC_HAND, IDC_ARROW)
SetCursor LoadCursor(0, lCursor)
End Sub



All times are GMT +1. The time now is 08:32 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com