找回密码
 加入
搜索
查看: 3449|回复: 7

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

  [复制链接]
发表于 2010-4-3 11:22:05 | 显示全部楼层 |阅读模式
本帖最后由 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


这样是不行的
 楼主| 发表于 2010-4-3 16:55:35 | 显示全部楼层
别给我沉了啊
发表于 2010-4-3 17:07:05 | 显示全部楼层
我也想知道~只知道可以用系统当前的鼠标风格
发表于 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[0]
EndFunc        ;==>_LoadCursorFromFile

评分

参与人数 1金钱 +30 收起 理由
afan + 30 学习了~

查看全部评分

发表于 2010-4-3 18:31:21 | 显示全部楼层
学习学习......
发表于 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

评分

参与人数 1金钱 +20 收起 理由
afan + 20

查看全部评分

 楼主| 发表于 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[0]
EndFunc

超级版主超级强大啊。如此就完美了。非常感谢。
 楼主| 发表于 2010-4-4 14:58:16 | 显示全部楼层
本帖最后由 xsjtxy 于 2010-4-4 15:07 编辑

还有一个问题。如何覆盖控件上的指针呢?
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-5-18 13:23 , Processed in 0.089270 second(s), 29 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表