Visual Basic. Программирование на Visual Basic

..........................................................................................................................

[ Главная ] [ Статьи ] [ Для новичков ] [ Примеры ] [ Программы ] [ Microsoft Agent 2.0 ] [ Пособие ] [ Уроки ] [ Разное ]
..........................................................................................................................



Использование анимационного курсора.
Добавьте 2 CommandButton на форму.

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

Или такой пример...

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



..........................................................................................................................

[ Главная ] [ Диски ] [ Книги ] [ Архив рассылки ] [ Архив новостей ] [ Готовые кусочки программ ] [ Карта сайта ]
..........................................................................................................................

По страницам сайта Visaul Progs
или Изучение Visual Basic
Рассылка 'По страницам сайта Visaul Progs' >>> Подпишись на рассылку - будешь получать новые статьи , примеры и много полезной информации из первых рук!!! >>>Если у вас есть статья которой нет на сайте
пришлите ее мне-------->
Послать статью
>>>Если вы хотите задать вопрос
пишите-------->
Мне нужна помощь


Рейтинг сайтов YandeG Rambler's Top100
Реклама:

...:::Design by Mystf0rse 2005-2010 year:::...