xsjtxy 发表于 2010-4-3 11:22:05

为GUI窗口定义指针[已解决]

本帖最后由 xsjtxy 于 2010-4-8 12:52 编辑

请教:如何加载一个ani指针文件"A.ani"为窗口指针呢?
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

$Form1 = GUICreate("Form1", 633, 454, 192, 114)
GUISetState(@SW_SHOW)

GUISetCursor("A.ani",1,$Form1)

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit

        EndSwitch
WEnd


这样是不行的

xsjtxy 发表于 2010-4-3 16:55:35

别给我沉了啊

myloveqmx 发表于 2010-4-3 17:07:05

我也想知道~只知道可以用系统当前的鼠标风格

pusofalse 发表于 2010-4-3 17:44:33

#include <WinAPI.au3>

$sCursorFile = "a.ani"
$hCursor = _LoadCursorFromFile($sCursorFile)

$hGUI = GUICreate("SetCursor", 400, 300)

$hGC = DllCallbackRegister("_SetCursorProc", "int", "hWnd;uint;wparam;lparam")
$hOGC = _WinAPI_SetWindowLong($hGUI, -4, DllCallbackGetPtr($hGC))

GUISetState()
While GUIGetMsg() <> -3
WEnd

GUIDelete($hGUI)
DllCallbackFree($hGC)
DllCall("User32.dll", "int", "DestroyCursor", "hWnd", $hCursor)

Func _SetCursorProc($hWnd, $iMsg, $iwParam, $ilParam)
        DllCall("User32.dll", "hWnd", "SetCursor", "hWnd", $hCursor)
        Return _WinAPI_CallWindowProc($hOGC, $hWnd, $iMsg, $iwParam, $ilParam)
EndFunc        ;==>_SetCursorProc

Func _LoadCursorFromFile($sCursorFile)
        Local $iResult
        $iResult = DllCall("User32.dll", "hWnd", "LoadCursorFromFile", "str", $sCursorFile)
        Return $iResult
EndFunc        ;==>_LoadCursorFromFile

lxz 发表于 2010-4-3 18:31:21

学习学习......

3mile 发表于 2010-4-3 18:59:32

借用HELP的内容:#include <GUIConstantsEx.au3>

Opt('MustDeclareVars', 1)

Global $IDC = -1, $newIDC = 0

Example()

Func Example()

        HotKeySet("{Esc}", "Increment")

        GUICreate("Press Esc to Increment", 400, 400, 0, 0, 0x04CF0000, 0x00000110)

        GUISetState()

        While GUIGetMsg() <> $GUI_EVENT_CLOSE
                If $newIDC <> $IDC Then
                        $IDC = $newIDC
                        GUISetCursor($IDC)
                EndIf
                ToolTip("GUI Cursor #" & $IDC)
        WEnd
EndFunc   ;==>Example

Func Increment()
        $newIDC = $IDC + 1
        If $newIDC > 15 Then $newIDC = 0
EndFunc   ;==>Increment

xsjtxy 发表于 2010-4-4 14:54:14

#include <WinAPI.au3>

$sCursorFile = "a.ani"
$hCursor = _LoadCursorFromFile($sCursorFile)
$hGUI = GUICreate("SetCursor", 400, 300)
GUISetCursor(16)
$hGC = DllCallbackRegister("_SetCursorProc", "int", "hWnd;uint;wparam;lparam")
$hOGC = _WinAPI_SetWindowLong($hGUI, -4, DllCallbackGetPtr($hGC))

GUISetState()

While GUIGetMsg() <> -3
WEnd

GUIDelete($hGUI)
DllCallbackFree($hGC)
DllCall("User32.dll", "int", "DestroyCursor", "hWnd", $hCursor)

Func _SetCursorProc($hWnd, $iMsg, $iwParam, $ilParam)
DllCall("User32.dll", "hWnd", "SetCursor", "hWnd", $hCursor)
Return _WinAPI_CallWindowProc($hOGC, $hWnd, $iMsg, $iwParam, $ilParam)
EndFunc      ;==>_SetCursorProc

Func _LoadCursorFromFile($sCursorFile)
Local $iResult
$iResult = DllCall("User32.dll", "hWnd", "LoadCursorFromFile", "str", $sCursorFile)
Return $iResult
EndFunc

超级版主超级强大啊。如此就完美了。非常感谢。

xsjtxy 发表于 2010-4-4 14:58:16

本帖最后由 xsjtxy 于 2010-4-4 15:07 编辑

还有一个问题。如何覆盖控件上的指针呢?
页: [1]
查看完整版本: 为GUI窗口定义指针[已解决]