Visual Basic, .NET, ASP, VBA, VBScript
 
  Библиотека кодов  
  Мышь и клавиатура  
     
  Использование анимационного курсора  
  Добавьте 2 CommandButton на форму
'ПРИМЕР 1

Const GCL_HCURSOR = -12
Private Declare Function ClipCursor Lib "user32" (lpRect As Any) As Long
Private Declare Function DestroyCursor Lib "user32" (ByVal hCursor As Any) As Long
Private Declare Function LoadCursorFromFile Lib "user32" Alias "LoadCursorFromFileA" (ByVal lpFileName As String) As Long
Private Declare Function SetClassLong Lib "user32" Alias "SetClassLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function GetClassLong Lib "user32" Alias "GetClassLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Dim lResult As Long
Dim mhAniCursor As Long
Dim mhAniCursor2 As Long
Private Sub Command1_Click()
'Replace 'C:\windows\cursors\hourglas.ani' with your ANI Cursor
mhAniCursor = LoadCursorFromFile("C:\windows\cursors\hourglas.ani")
lResult = SetClassLong((hwnd), GCL_HCURSOR, mhAniCursor)
End Sub
Private Sub Command2_Click()
lResult = SetClassLong((hwnd), GCL_HCURSOR, mhBaseCursor)
lResult = DestroyCursor(mhAniCursor)
End Sub
Private Sub Form_Load()
mhBaseCursor = GetClassLong((hwnd), GCL_HCURSOR)
End Sub
Private Sub Form_Unload(Cancel As Integer)
lResult = SetClassLong((hwnd), GCL_HCURSOR, mhBaseCursor)
lResult = DestroyCursor(mhAniCursor)
End Sub

'ПРИМЕР 2

Private Declare Function CopyCursor Lib "user32" Alias "CopyIcon" (ByVal hcur As Long) As Long
Private Declare Function GetCursor Lib "user32" () As Long
Private 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 = 32512
Dim hCursor As Long, hOldCursor As Long

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If hCursor = 0 Then
Dim lRet As Long, a As String, hInstance As Long, hImage As Long
'укажите правильную директорию Windows
a = "c:\win\cursors\" & Dir$("c:\win\cursors\*.ani")
hCursor = LoadCursorFromFile(a)
If hCursor Then
lRet = GetCursor()
hOldCursor = CopyCursor(lRet)
lRet = SetSystemCursor(hCursor, OCR_NORMAL)
End If
End If
End Sub

Private Sub Form_Unload(Cancel As Integer)
Dim lRet As Long
If hCursor Then
lRet = SetSystemCursor(hOldCursor, OCR_NORMAL)
End If
End Sub
 
     
  VBNet online (всего: 51586)  
 

Логин:

Пароль:

Регистрация, забыли пароль?


В чате сейчас человек
 
     
  VBNet рекомендует  
   
     
  Лучшие материалы  
 
ActiveX контролы (112)
Hitman74_Library (36119)
WindowsXPControls (20739)
FlexGridPlus (19374)
DSMAniGifControl (18295)
FreeButton (15157)
Примеры кода (546)
Parol (18027)
Passworder (9299)
Screen saver (7654)
Kerish AI (5817)
Folder_L (5768)
Статьи по VB (136)
Мое второе впечатление... (11236)
VB .NET: дорога в будущее (11161)
Основы SQL (9225)
Сообщения Windows в Vi... (8788)
Классовая теория прогр... (8619)
 
     
Техническая поддержка MTW-хостинг | © Copyright 2002-2011 VBNet.RU | Пишите нам