Private Sub Command1_Click() dim filePath as String filePath=从注册表中得到文件名及路径 Me.MousePointer = 99 Me.MouseIcon = filePath End Sub
'2 API: 'ADD A BLANK FORM AND PASTE THE FOLLOWING CODES TO IT ,THEN LEFT MOUSE DOWN OR RIGHT MOUSE DOWNOption ExplicitPrivate Declare Function LoadCursorFromFile Lib "user32" Alias "LoadCursorFromFileA" (ByVal lpFileName As String) As Long Private Declare Function SetSystemCursor Lib "user32" (ByVal hcur As Long, ByVal id As Long) As Long Private Const OCR_NORMAL = 32512Dim newcursor As Long Dim cursors As New CollectionSub loadcursors() ' load cursors from system Dim mydir As String, fname As Stringmydir = Environ("windir") & "\cursors\" fname = Dir(mydir) Do While fname <> "" cursors.Add mydir & fname fname = Dir Loop End SubSub loaddefaultcursor() Dim defaultcursor As Long ' set default system cursor defaultcursor = LoadCursorFromFile(Environ("windir") & "\cursors\arrow_l.cur") SetSystemCursor defaultcursor, OCR_NORMAL End Sub Sub loadnewcursor() ' set a new system cursor Dim cursorfile As String Randomize cursorfile = cursors(Int(Rnd * cursors.Count + 1)) 'random cursor file newcursor = LoadCursorFromFile(cursorfile) SetSystemCursor newcursor, OCR_NORMAL Me.Caption = cursorfile End Sub Private Sub Form_Load() loadcursors End SubPrivate Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) If Button = 1 Then loadnewcursor If Button = 2 Then loaddefaultcursor End SubPrivate Sub Form_Unload(Cancel As Integer) ' default system cursor loaddefaultcursor End Sub
dim filePath as String
filePath=从注册表中得到文件名及路径
Me.MousePointer = 99
Me.MouseIcon = filePath
End Sub
'ADD A BLANK FORM AND PASTE THE FOLLOWING CODES TO IT ,THEN LEFT MOUSE DOWN OR RIGHT MOUSE DOWNOption ExplicitPrivate Declare Function LoadCursorFromFile Lib "user32" Alias "LoadCursorFromFileA" (ByVal lpFileName As String) As Long
Private Declare Function SetSystemCursor Lib "user32" (ByVal hcur As Long, ByVal id As Long) As Long
Private Const OCR_NORMAL = 32512Dim newcursor As Long
Dim cursors As New CollectionSub loadcursors() ' load cursors from system
Dim mydir As String, fname As Stringmydir = Environ("windir") & "\cursors\"
fname = Dir(mydir)
Do While fname <> ""
cursors.Add mydir & fname
fname = Dir
Loop
End SubSub loaddefaultcursor()
Dim defaultcursor As Long ' set default system cursor
defaultcursor = LoadCursorFromFile(Environ("windir") & "\cursors\arrow_l.cur")
SetSystemCursor defaultcursor, OCR_NORMAL
End Sub
Sub loadnewcursor() ' set a new system cursor
Dim cursorfile As String
Randomize
cursorfile = cursors(Int(Rnd * cursors.Count + 1)) 'random cursor file
newcursor = LoadCursorFromFile(cursorfile)
SetSystemCursor newcursor, OCR_NORMAL
Me.Caption = cursorfile
End Sub
Private Sub Form_Load()
loadcursors
End SubPrivate Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then loadnewcursor
If Button = 2 Then loaddefaultcursor
End SubPrivate Sub Form_Unload(Cancel As Integer) ' default system cursor
loaddefaultcursor
End Sub