Mingre Posted May 13, 2012 Share Posted May 13, 2012 Hello Forums, The only relevant function I found in the helpfile is GUICtrlSetCursor() but it changes the cursor over the entire listview control. Thanks. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 13, 2012 Moderators Share Posted May 13, 2012 Lilbert, So when do you want the cursor to change? Please give us some more hints - or much better post some code showing the listview you are using and tell us the areas where you want the cursor to change. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Mingre Posted May 14, 2012 Author Share Posted May 14, 2012 Melba23, Sorry for being vague. Here's a sample script: expandcollapse popup#include <Array.au3> #include <Constants.au3> #include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <File.au3> #include <ListviewConstants.au3> #include <SendMessage.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> Global $iIndex = -1, $iSubIndex = -1, $no = 3, $_Files[$no], $asFiles[$no], $hGUI_ListView[$no], $hListView[$no], $hGUI_ListView_ImageList[$no] Global $sFolderPath[$no] = [@DesktopDir, 'C:', 'D:'] $hGUI = GUICreate('GUI', 250, @DesktopHeight / 2) $a = 0 ;For $a = 0 To $no - 1 Step +1 $asFiles = _FileListToArray($sFolderPath[$a]) $_size = UBound($asFiles) If Not IsDeclared('_Compare') Then Dim $_Files[$no][$_size] Local $_Compare = $_size Else If $_size > $_Compare Then ReDim $_Files[$no][$_size] EndIf $hGUI_ListView[$a] = GUICtrlCreateListView($a, $a * 250, 0, 250, @DesktopHeight / 2) GUICtrlSetCursor ( -1, 14) ; <<<<<<<<<< $hListView[$a] = GUICtrlGetHandle($hGUI_ListView[$a]) GUICtrlSetStyle($hGUI_ListView[$a], BitOR($LVS_ICON, $LVS_SINGLESEL, $LVS_SHOWSELALWAYS, $LVS_NOCOLUMNHEADER), BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_FLATSB)) For $i = 1 To $asFiles[0] $lvitem = GUICtrlCreateListViewItem($asFiles[$i], $hGUI_ListView[$a]) GUICtrlSetImage($lvitem, "shell32.dll", 224) Next ;Next GUISetState(@SW_SHOW) GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE _exit() EndSwitch WEnd #region - Functions Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) #forceref $hWnd, $iMsg, $iwParam Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") For $c = 0 To $no - 1 Step +1 If $hWndFrom = $hListView[$c] Then If $iCode = $NM_DBLCLK Then _dblclk($c) ElseIf $iCode = $NM_KILLFOCUS Then ControlListView('','',$hListView[$c],"SelectClear") EndIf EndIf Next Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY Func _dblclk($no) Local $aHit = _GUICtrlListView_SubItemHitTest($hListView[$no]) If ($aHit[0] <> -1) And (($aHit[0] <> $iIndex) Or ($aHit[1] <> $iSubIndex)) Then $_filename = $sFolderPath[$no] & '' & $_Files[$no][$aHit[0] + 1] ConsoleWrite(@CRLF & 'Double click ' & @CRLF & $_filename & @CRLF) EndIf EndFunc ;==>_execute Func _exit() Exit EndFunc ;==>_exit #endregion - Functions I'd like to have the cursor change only when it is placed over the icons. Would that be possible? Thanks! Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 14, 2012 Moderators Share Posted May 14, 2012 Lilbert,The only thing I can think of is to use _GUICtrlListView_GetItemRect to find the coordinates of the icons and change the cursor when it is withint those coordinates. But that seems a very complex and CPU intensive way of going about things. I am sure someone else will have a better idea. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
rover Posted May 14, 2012 Share Posted May 14, 2012 I'd like to have the cursor change only when it is placed over the icons. Would that be possible? Use hit test to check if mouse is over icon in LVN_HOTTRACK notification. Notification still sent even if listview doesn't have hot tracking enabled with LVS_EX_TRACKSELECT expandcollapse popup#include <Array.au3> #include <Constants.au3> #include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <File.au3> #include <ListviewConstants.au3> #include <SendMessage.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> Global $iIndex = -1, $iSubIndex = -1, $no = 3, $_Files[$no], $asFiles[$no], $hGUI_ListView[$no] =[0,0,0], $hListView[$no], $hGUI_ListView_ImageList[$no] Global $sFolderPath[$no] = [@DesktopDir, 'C:', 'D:'] $hGUI = GUICreate('GUI', 250, @DesktopHeight / 2) $a = 0 ;For $a = 0 To $no - 1 Step +1 $asFiles = _FileListToArray($sFolderPath[$a]) $_size = UBound($asFiles) If Not IsDeclared('_Compare') Then Dim $_Files[$no][$_size] Local $_Compare = $_size Else If $_size > $_Compare Then ReDim $_Files[$no][$_size] EndIf $hGUI_ListView[$a] = GUICtrlCreateListView($a, $a * 250, 0, 250, @DesktopHeight / 2) $hListView[$a] = GUICtrlGetHandle($hGUI_ListView[$a]) GUICtrlSetStyle($hGUI_ListView[$a], BitOR($LVS_ICON, $LVS_SINGLESEL, $LVS_SHOWSELALWAYS, $LVS_NOCOLUMNHEADER), BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_FLATSB)) For $i = 1 To $asFiles[0] $lvitem = GUICtrlCreateListViewItem($asFiles[$i], $hGUI_ListView[$a]) GUICtrlSetImage($lvitem, "shell32.dll", 224) Next ;Next GUISetState(@SW_SHOW) GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE _Exit() EndSwitch WEnd #region - Functions Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) #forceref $hWnd, $iMsg, $iwParam Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $hWndFrom = DllStructGetData($tNMHDR, "hWndFrom") ;this use of HWnd() is a leftover from the old incorrect tagNMHDR struct from years ago $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $iIDFrom ;better than looping, faster than checking handles with WinGetClassList = SysHeader32 or _WinAPI_GetClassName = SysListView32 Case $hGUI_ListView[0], $hGUI_ListView[1], $hGUI_ListView[2] ;better to compare integer control ID instead of handle, listview handles available in $hWndFrom Switch $iCode Case $NM_DBLCLK _dblclk($hWndFrom) ;use handle, as hit test functions do not convert ID to handle Case $NM_KILLFOCUS ControlListView($hWndFrom, '', $hWndFrom, "SelectClear") ;use with handles, otherwise a search for window is done each time called Case $LVN_HOTTRACK; Sent by a list-view control when the user moves the mouse over an item Local $tInfo = DllStructCreate($tagNMLISTVIEW, $ilParam) If DllStructGetData($tInfo, "Item") = -1 Then GUICtrlSetCursor($iIDFrom, -1) ;not over item Return 1 EndIf Local $aHit = _GUICtrlListView_HitTest($hWndFrom);use handle, as hit test functions do not convert ID to handle If @error Then Return 1 If $aHit[2] Then GUICtrlSetCursor($iIDFrom, 14) ;over icon - includes wide margin on left/right of icon, may be due to internal imagelist size or some MS design decision. Else GUICtrlSetCursor($iIDFrom, -1) ;over item text EndIf EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY Func _dblclk($hWnd) Local $aHit = _GUICtrlListView_SubItemHitTest($hWnd), $iI = 0 If @error Then Return 1 If ($aHit[0] <> -1) And (($aHit[0] <> $iIndex) Or ($aHit[1] <> $iSubIndex)) Then For $i = 0 To UBound($hListView) - 1 If $hListView[$i] = $hWnd Then $iI = $i ; For loop auto declared $i is not valid outside loop ExitLoop EndIf Next $_filename = $sFolderPath[$iI] & '\' & $asFiles[$aHit[0] + 1] ConsoleWrite(@CRLF & 'Double click ' & @CRLF & $_filename & @CRLF) EndIf EndFunc ;==>_dblclk Func _Exit() Exit EndFunc ;==>_Exit #endregion - Functions I see fascists... Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now