Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mouse cursor --- How to change?

Status
Not open for further replies.

TomCarnahan

Programmer
Dec 7, 2002
123
US
I am using a technique to "emulate" drag and drop between two listboxes in a form. The technique is a little involved to list here, but the one thing it does not do is change the image of the mouse cursor.

I am aware of how to use the "hourglass" property, but I don't know how to change the image of the hourglass with VBA. I have searched the archives and didn't see anything.

Can you help?

--- Tom
 
Do you mean this:

DoCmd.Hourglass True

Or, are you looking to change the cursor to some other image?
 
The second ... I want to change the image during the "drag" phase. Microsoft's Help file aludes to the fact that it can be done, but then never tells where to find the info.

I know that VBA in Excel lets you change the cursor to several pre-defined icons. I would like the cursor to look like the case when you drag a file into a window from your desktop.

Any ideas?


--- Tom

--- Tom
 
Hi,

You can do this using a couple of API's. Paste this into a module:
Declare Function LoadCursorFromFile Lib "user32.dll" Alias "LoadCursorFromFileA" (ByVal lpFileName As String) As Long
Declare Function SetCursor Lib "user32.dll" (ByVal hCursor As Long) As Long

Public Function Set_Custom_Cursor()
Dim hCursor As Long, strCursor As String
strCursor = Application.CurrentProject.Path & "\Mouse.ani"
hCursor = LoadCursorFromFile(strCursor)
SetCursor (hCursor)
End Function

To call it, place this in the On Mouse Down event of your List Box or a Form/Control:
Set_Custom_Cursor


I have posted a working version of this at: using a simplified Drag and Drop example of my own.

The file to look at is: Mouse Cursor/ Drag Drop 2000 I have also included the cursor (Mouse.ani), which you should place in the same folder as the DB. This code should work with any cursor though, animated or otherwise.

Bill
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top