Changing Cursor Shape

beeky

Registered User.
Local time
Today, 11:05
Joined
Jan 11, 2010
Messages
39
I used to be able to change the cursor to a hand shape in Access XP by using the code below in the On Mouse Move event property:

Private Sub Label16_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Call MouseCursor(32649) 'Display hand cursor
End Sub

This no longer works. Is there an updated method for doign this in Access 2010?
 
Hi;

Paste a new module;

Option Explicit
Declare Function adiSWA_LoadCursorByNum Lib "user32" Alias "LoadCursorA" _
(ByVal hInstance As Long, ByVal lpCursorName As Long) As Long
Declare Function adiSWA_LoadCursorFromFile Lib "user32" Alias _
"LoadCursorFromFileA" (ByVal lpFileName As String) As Long
Declare Function adiSWA_adiSetCursor Lib "user32" Alias "SetCursor" _
(ByVal hCursor As Long) As Long

Function SSF_DsplyMouseCursor(sCursorType As String) As Boolean
'---------------------------------------------
' Action(s) : Changes the mouse cursor to the type indicated by sCursorType.
' Comments : Typically called from an object's MouseMove event
' Protocol : =SSF_DsplyMouseCursor("Hand")
'---------------------------
' Argument Description
' -------- -----------
' sCursorType Cursor type desired, as specified below
'Hand
'AppStarting
'No
'Wait
'Arrow
'Cross
'SizeAll
'SizeNESW
'SizeNS
'SizeNWSE
'SizeWE
'UpArrow
'---------------------------
Dim sCursors As String
Dim iCursorPos As Integer
Dim lCursorType As Long
sCursors = "Hand32649AppStarting32650No32648Wait32514Arrow32512Cross32515SizeAll32646SizeNESW32643SizeNS32645SizeNWSE32642SizeWE32644UpArrow32516"
iCursorPos = InStr(1, sCursors, sCursorType)
lCursorType = Mid(sCursors, iCursorPos + Len(sCursorType), 5)
Call adiSWA_adiSetCursor(adiSWA_LoadCursorByNum(0&, lCursorType))
End Function


Or :

Private Sub Label16_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim HCur As Long ' receives handle to the loaded cursor
Dim holdcursor As Long ' receives handle to the previously in use cursor
Dim retval As Long ' throw-away return value

'If Button And acLeftButton Then
HCur = adiSWA_LoadCursorFromFile("C:\Windows\Cursors\hmove.cur") ' load
If HCur = 0 Then End ' abort program if cursor couldn't be loaded
holdcursor = adiSWA_adiSetCursor(HCur) ' set the loaded cursor as the current cursor
'End If
End Sub


Works in Access 2010
 
Last edited:
Thanks JPauo

I have created a new module and called it ModLoadCursorHand. Sorry to be thick but what do I do with it now. For example if this was an event proceedure for "On Mouse Move" I would simply place it in a sub for On Mouse Move. In other words how do I make it work and what else do I need to do. As you have probably gathered I am learning as I go along.
 
1º Or paste that =SSF_DsplyMouseCursor( "Hand") in the event line

Or

Simply use the 2ª option

Private Sub Label16_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim HCur As Long ' receives handle to the loaded cursor
Dim holdcursor As Long ' receives handle to the previously in use cursor
Dim retval As Long ' throw-away return value

'If Button And acLeftButton Then
HCur = adiSWA_LoadCursorFromFile("C:\Windows\Cursors\hmov e.cur") ' load
If HCur = 0 Then End ' abort program if cursor couldn't be loaded
holdcursor = adiSWA_adiSetCursor(HCur) ' set the loaded cursor as the current cursor
'End If
End Sub
 
Here's a more "user-friendly" and cut-down version.

Paste into module:
Code:
Option Compare Database
Option Explicit

' Declarations for setting the cursor icon when called
Public Const IDC_HAND = 32649&
Public Const IDC_ARROW = 32512&
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

How to call (using the module name you saved JPaulo's version as):
Code:
ModLoadCursorHand.SetCursor LoadCursor(0, IDC_HAND)
That would set it to the hyperlink hand.

Code:
ModLoadCursorHand.SetCursor LoadCursor(0, IDC_ARROW)
Back to default.
 
Hi all, i have made a drag n drop in access 2003.
I want to change the cursor when dragging to the value that i drag?
is that possible?


thx in advance and sorry for my english.
 
Here's a more "user-friendly" and cut-down version.

Paste into module:
Code:
Option Compare Database
Option Explicit

' Declarations for setting the cursor icon when called
Public Const IDC_HAND = 32649&
Public Const IDC_ARROW = 32512&
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

How to call (using the module name you saved JPaulo's version as):
Code:
ModLoadCursorHand.SetCursor LoadCursor(0, IDC_HAND)
That would set it to the hyperlink hand.

Code:
ModLoadCursorHand.SetCursor LoadCursor(0, IDC_ARROW)
Back to default.

Hi

I have tried using the above but the cursor keep flickering when moved over a text field. is there any way to make it not to flicker?
 
Just for the benefit of others who might not notice, you have responded to an 8 year old thread. I'm no moderator here but maybe the right thing to do is start your own. I'm sure someone will let me know if I'm out of line.
 

Users who are viewing this thread

Back
Top Bottom