Что нового

[Элементы GUI] Определённый курсор в своём окне

_Lexa98_

Осваивающий
Сообщения
551
Репутация
25
Как сделать определённый курсор в окне?
 

Zaramot

I ♥ AutoIt
Сообщения
1,160
Репутация
660
Смотри в справке:
Код:
GUISetCursor()


Или вот:
Код:
#include <GUIConstantsEx.au3>

Global $CURSOR = @ScriptDir & '\1.cur'

$Form1 = GUICreate("Form1", 633, 449, 192, 124)
GUISetState()

While 1
	If GetHoveredHwnd() = $Form1 Then
        _SetCursor($CURSOR, 32512)
    Else
		DllCall("user32.dll", "int", "SystemParametersInfo", "int", 0x57, "int", 0, "int", 0, "int", 0)
    EndIf

	$nMsg = GUIGetMsg()
	Switch $nMsg
		Case $GUI_EVENT_CLOSE
			DllCall("user32.dll", "int", "SystemParametersInfo", "int", 0x57, "int", 0, "int", 0, "int", 0)
			Exit
	EndSwitch
WEnd

Func _SetCursor($s_file, $i_cursor)
   Local $newhcurs, $lResult
   $newhcurs = DllCall("user32.dll", "int", "LoadCursorFromFile", "str", $s_file)
   If Not @error Then
      $lResult = DllCall("user32.dll", "int", "SetSystemCursor", "int", $newhcurs[0], "int", $i_cursor)
      If Not @error Then
         $lResult = DllCall("user32.dll", "int", "DestroyCursor", "int", $newhcurs[0])
      Else
         MsgBox(0, "Error", "Failed SetSystemCursor")
      EndIf
   Else
      MsgBox(0, "Error", "Failed LoadCursorFromFile")
   EndIf
EndFunc ;==>_SetCursor

Func GetHoveredHwnd()
    Local $iRet = DllCall("user32.dll", "int", "WindowFromPoint", "long", MouseGetPos(0), "long", MouseGetPos(1))
    If IsArray($iRet) Then Return HWnd($iRet[0])
    Return SetError(1, 0, 0)
EndFunc


Курсор: 1.cur
 

Yashied

Модератор
Команда форума
Глобальный модератор
Сообщения
5,379
Репутация
2,724
Автор
_Lexa98_

_Lexa98_

Осваивающий
Сообщения
551
Репутация
25
Спасибо всем!

Zaramot
Дьявольский курсор ;D
 
Автор
_Lexa98_

_Lexa98_

Осваивающий
Сообщения
551
Репутация
25
Zaramot
Я так и подумал :D
 
Верх