Jump to content

Cursors


GaryFrost
 Share

Recommended Posts

Include File: Cursor.au3

Example:

#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
#include <GuiStatusBar.au3>
#include <WindowsConstants.au3>
#include <StructureConstants.au3>
#include <Cursor.au3>

$Debug_LV = False ; Check ClassName being passed to ListView functions, set to True and use a handle to another control to see it work

Global $hListView, $hStatus, $hCursor

Example_Internal()

Func Example_Internal()
    Local $hGUI, $tCURSORINFO, $aCurPos, $sRow

    $hGUI = GUICreate("(Internal) ListView Get Hot Item", 392, 322)
    
    $hListView = GUICtrlCreateListView("", 2, 2, 394, 268)
    $hListView = GUICtrlGetHandle($hListView)
    _GUICtrlListView_SetExtendedListViewStyle($hListView, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES, $LVS_EX_TRACKSELECT))
    $hStatus = _GUICtrlStatusBar_Create($hGUI)
    _GUICtrlStatusBar_SetSimple($hStatus, True)
    GUISetState()

    ; Add columns
    _GUICtrlListView_AddColumn($hListView, "Column 1", 100)
    _GUICtrlListView_AddColumn($hListView, "Column 2", 100)
    _GUICtrlListView_AddColumn($hListView, "Column 3", 100)

    ; Add items
    For $i = 0 To 20
        $sRow = "Row " & StringFormat("%.02u", $i)
        _GUICtrlListView_AddItem($hListView, $sRow & ": Col 1")
        _GUICtrlListView_AddSubItem($hListView, $i, $sRow & ": Col 2", 1)
        _GUICtrlListView_AddSubItem($hListView, $i, $sRow & ": Col 3", 2)
    Next

    _DebugPrint("Show: " & _Cursor_Show(False))
    Sleep(3000)
    _DebugPrint("Show: " & _Cursor_Show())

;~  $hCursor = _Cursor_LoadFromFile(@WindowsDir & "\Cursors\handapst.ani")
    $hCursor = _Cursor_LoadFromFile(@WindowsDir & "\Cursors\banana.ani")
;~    $hCursor = _Cursor_LoadFromFile(@WindowsDir & "\Cursors\h_arrow.cur")
    _DebugPrint("$hCursor: " & $hCursor)
    ;Register WM_NOTIFY  events
    GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
    _DebugPrint("Current Cursor: " & _Cursor_Get())
    $tCURSORINFO = _Cursor_GetInfo(_Cursor_Get())
    _DebugPrint("GetInfo:" & @LF & "Showing: " & StringFormat("%s", DllStructGetData($tCURSORINFO, "Flags") <> 0) & _
            @LF & "X......: " & DllStructGetData($tCURSORINFO, "X") & @LF & "Y......: " & DllStructGetData($tCURSORINFO, "Y"))
    $aCurPos = _Cursor_GetPos()
    _DebugPrint("GetPos" & @LF & "X......: " & $aCurPos[0] & @LF & "Y......: " & $aCurPos[1])
;~  $aCurPos = _Cursor_GetPhysicalPos()
;~  _DebugPrint("GetPhysicalPos" & @LF & "X......: " & $aCurPos[0] & @LF & "Y......: " & $aCurPos[1])
    _DebugPrint("SetPos: " & _Cursor_SetPos($aCurPos[0] + 50, $aCurPos[1] + 50))
;~  _DebugPrint("SetPhysicalPos: " & _Cursor_SetPhysicalPos($aCurPos[0] - 10, $aCurPos[1] - 20))

    ; Loop until user exits
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    _DebugPrint("Destroy: " & _Cursor_Destroy($hCursor))
    GUIDelete()
EndFunc   ;==>Example_Internal

Func ListView_HOTTRACK($iItem, $iSubItem)
    #forceref $iItem
    Local $HotItem = _GUICtrlListView_GetHotItem($hListView)
    If $HotItem <> -1 Then _GUICtrlStatusBar_SetText($hStatus, "Hot Item: " & $HotItem & " SubItem: " & $iSubItem)
EndFunc   ;==>ListView_HOTTRACK

Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
    #forceref $hWnd, $iMsg, $iwParam
    Local $hWndFrom, $iCode, $tNMHDR, $hWndListView
    $hWndListView = $hListView
    If Not IsHWnd($hListView) Then $hWndListView = GUICtrlGetHandle($hListView)
    $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
        Case $hWndListView
            Switch $iCode
                Case $LVN_HOTTRACK Or $NM_LDOWN ; Sent by a list-view control when the user moves the mouse over an item
                    _Cursor_Set($hCursor)
                    If $iCode = $LVN_HOTTRACK Then
                        Local $tInfo = DllStructCreate($tagNMLISTVIEW, $ilParam)
                        ListView_HOTTRACK(DllStructGetData($tInfo, "Item"), DllStructGetData($tInfo, "SubItem"))
                        Return 0
                    EndIf
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY

Func _DebugPrint($s_text, $line = @ScriptLineNumber)
    $s_text = StringReplace($s_text, @LF, @LF & "-->: ")
    ConsoleWrite( _
            "!===========================================================" & @LF & _
            "+======================================================" & @LF & _
            "-->Line(" & StringFormat("%04d", $line) & "):" & @TAB & $s_text & @LF & _
            "+======================================================" & @LF)
EndFunc   ;==>_DebugPrint

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

Cool Beans.. LOL Or should I say Bananas.. Nice, Thanks Gary.. :)

Cool Gary,

so now it is possibel to load a different cursor and after it restore default?!

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

Cool Gary,

so now it is possibel to load a different cursor and after it restore default?!

Mega

You could, you would have to save the handle from the 1st call to _Cursor_Set it returns the Handle to the previous cursor, if there was one

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...