本帖最后由 298311657 于 2015-10-11 19:28 编辑
2015.10.11 更新了一下代码,使光标在控件上也不变回系统光标。(附件未更新)#AutoIt3Wrapper_UseX64=n
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>
$GUI = GUICreate("动画鼠标指针展示", 560, 385)
GUICtrlCreateLabel("动画鼠标指针展示", 60, 80, 140, 20)
GUICtrlSetBkColor(-1, 0x9c9c9c)
$button = GUICtrlCreateButton("动画鼠标指针展示", 60, 120, 125, 25)
GUISetState(@SW_SHOW, $GUI)
$mhAniCursor = _WinAPI_LoadCursorFromFile("cursor.ani")
If $mhAniCursor Then GUIRegisterMsg(32, "WM_SETCURSOR")
GUIRegisterMsg($WM_NCHITTEST, 'WM_NCHITTEST')
While 1
Switch GUIGetMsg()
Case -3
Exit
Case $button
MsgBox(0,"","动画鼠标指针展示",0,$GUI)
EndSwitch
WEnd
Func _WinAPI_LoadCursorFromFile($sFile)
Local $Ret = DllCall('user32.dll', 'ptr', 'LoadCursorFromFileW', 'wstr', $sFile)
If (@error) Or ($Ret[0] = 0) Then
Return SetError(1, 0, 0)
EndIf
Return $Ret[0]
EndFunc ;==>_WinAPI_LoadCursorFromFile
Func WM_SETCURSOR($HWND, $IMSG, $IWPARAM, $ILPARAM)
If $HWND Then
DllCall("user32.dll", "int", "SetCursor", "int", $mhAniCursor)
Return 1
EndIf
EndFunc ;==>WM_SETCURSOR
Func WM_NCHITTEST($hWnd, $iMsg, $iwParam, $ilParam)
If _WinAPI_DefWindowProc($hWnd, $iMsg, $iwParam, $ilParam) = $HTCLIENT Then
Return $HTCAPTION
EndIf
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_NCHITTEST
|