AutoBert Posted August 26, 2022 Share Posted August 26, 2022 I am writing a iconLVw4.au3, it work's fine with this expandcollapse popupFunc WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $sIcon, $tInfo, $iIndex, $iSub, $sRes, $aPos $sDLLName = GUICtrlRead($Combo) $hWndListView = $hListview If Not IsHWnd($hListview) Then $hWndListView = GUICtrlGetHandle($hListview) $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hWndListView Switch $iCode Case $NM_RCLICK ; Sent by a list-view control when the user clicks an item with the right mouse button $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam) $iIndex = DllStructGetData($tInfo, "Index") $iSub = DllStructGetData($tInfo, "SubItem") $sRes = _GUICtrlListView_GetItemText($hListview, $iIndex, $iSub) ConsoleWrite($iCode & @TAB & 'iIndex: ' & $iIndex & @TAB & 'iSub: ' &$iSub & @TAB & 'Text: ' & $sRes & @CRLF) if $iSub > 0 Then GUICtrlSetData($inpID, $sRes) $sIcon = @SystemDir & '\' & $sDLLName $sRes = -(1 + $sRes) ConsoleWrite($sIcon & @TAB & $sRes & @CRLF) GUICtrlSetImage($IconPreview, $sIcon, $sRes) EndIf Case Else ;TO DO check out what's the best msg for get both idex + subindex ;$LVN_GETINFOTIPA, $LVN_GETINFOTIPW, $NM_HOVER didn't work for subindex $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam) $iIndex = DllStructGetData($tInfo, "Index") $iSub = DllStructGetData($tInfo, "SubItem") $sRes = _GUICtrlListView_GetItemText($hListview, $iIndex, $iSub) ConsoleWrite($iCode & @TAB & 'ItemIndex: ' & $iIndex & @TAB & 'SubIndex: ' &$iSub & @TAB & 'Text: ' & $sRes & @CRLF) $aPos = MouseGetPos() If $iSub = 0 Then ToolTip('Zum späteren Speichern an-"Checken" (Mehrfachspeichern) um ganze Zeile zum Speichern zu übernehmen') Else ToolTip('Rechtsklick um IconID für (Einzel-) Speichern zu übernehmen', $aPos[0]+20, $aPos[1]+10) EndIf ; Return 0 EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY the iCode $NM_RCLICK works and also to geting the info with case else is working. But the ToolTips are a little bit nervous (flickring). So i am searching for a better way. The console output for a short test-session: >"C:\Program Files (x86)\AutoIt3\SciTE\..\AutoIt3.exe" "C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3" /run /prod /ErrorStdOut /in "C:\Users\(len)Bert\AutoIt\Icon-Viewer\iconLVw4.au3" /UserParams +>18:15:53 Starting AutoIt3Wrapper (21.316.1639.1) from:SciTE.exe (4.4.6.0) Keyboard:00000407 OS:WIN_10/2009 CPU:X64 OS:X64 Environment(Language:0407) CodePage:0 utf8.auto.check:4 +> SciTEDir => C:\Program Files (x86)\AutoIt3\SciTE UserDir => C:\Users\(len)Bert\AppData\Local\AutoIt v3\SciTE\AutoIt3Wrapper SCITE_USERHOME => C:\Users\(len)Bert\AppData\Local\AutoIt v3\SciTE >Running AU3Check (3.3.16.0) from:C:\Program Files (x86)\AutoIt3 input:C:\Users\(len)Bert\AutoIt\Icon-Viewer\iconLVw4.au3 +>18:15:55 AU3Check ended.rc:0 >Running:(3.3.16.0):C:\Program Files (x86)\AutoIt3\autoit3_x64.exe "C:\Users\(len)Bert\AutoIt\Icon-Viewer\iconLVw4.au3";NM_RClick C:\WINDOWS\system32\shell32.dll -140 -121 ItemIndex: 8 SubIndex: 12 Text: 139 -121 ItemIndex: 8 SubIndex: 12 Text: 139 -121 ItemIndex: 8 SubIndex: 12 Text: 139 -121 ItemIndex: 7 SubIndex: 12 Text: 123 -121 ItemIndex: 7 SubIndex: 12 Text: 123 -121 ItemIndex: 6 SubIndex: 13 Text: 108 -121 ItemIndex: 6 SubIndex: 14 Text: 109 -121 ItemIndex: 5 SubIndex: 14 Text: 93 -121 ItemIndex: 5 SubIndex: 15 Text: 94 -121 ItemIndex: 4 SubIndex: 15 Text: 78 -121 ItemIndex: 4 SubIndex: 15 Text: 78 -121 ItemIndex: 4 SubIndex: 15 Text: 78 -121 ItemIndex: 3 SubIndex: 15 Text: 62 -121 ItemIndex: 3 SubIndex: 16 Text: 63 -121 ItemIndex: 2 SubIndex: 16 Text: 47 -121 ItemIndex: 2 SubIndex: 16 Text: 47 -121 ItemIndex: 2 SubIndex: 16 Text: 47 -12 ItemIndex: 1 SubIndex: 32763 Text: -12 ItemIndex: 65537 SubIndex: 32763 Text: -121 ItemIndex: 2 SubIndex: 16 Text: 47 -121 ItemIndex: 2 SubIndex: 16 Text: 47 -8 ItemIndex: 0 SubIndex: 0 Text: -12 ItemIndex: 1 SubIndex: 0 Text: -12 ItemIndex: 65537 SubIndex: 0 Text: -12 ItemIndex: 65537 SubIndex: 0 Text: shell32.dll | 139| 32x32|32x32 C:\Users\(len)Bert\Pictures\Icons\shell32_139.ico Link to comment Share on other sites More sharing options...
kurtykurtyboy Posted August 27, 2022 Share Posted August 27, 2022 It looks like you are getting some interference with some random notification codes that you don't care about - like the "-12" when crossing the border between items. I would use $LVN_HOTTRACK for what you are trying to accomplish. Case $LVN_HOTTRACK ;~ $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam) $tInfo = DllStructCreate($tagNMLISTVIEW, $ilParam) $iIndex = DllStructGetData($tInfo, "Index") $iSub = DllStructGetData($tInfo, "SubItem") But now there is still another issue. For some reason, the tagNMLISTVIEW struct is returning sub-item 0 about half-way through sub-item 1, depending on how wide the column is set. No idea what is going on there, but one easy way to solve this is to use _GUICtrlListView_SubItemHitTest instead. Case $LVN_HOTTRACK ;~ $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam) ;~ $tInfo = DllStructCreate($tagNMLISTVIEW, $ilParam) ;~ $iIndex = DllStructGetData($tInfo, "Index") ;~ $iSub = DllStructGetData($tInfo, "SubItem") Local $aSubItemHitTest = _GUICtrlListView_SubItemHitTest($hListview) If $aSubItemHitTest[0] <> -1 Then $iIndex = $aSubItemHitTest[0] $iSub = $aSubItemHitTest[1] $sRes = _GUICtrlListView_GetItemText($hListview, $iIndex, $iSub) ConsoleWrite('Code: ' & $iCode & @TAB & 'ItemIndex: ' & $iIndex & @TAB & 'SubIndex: ' &$iSub & @TAB & 'Text: ' & $sRes & @CRLF) $aPos = MouseGetPos() If $iSub = 0 Then ToolTip('Zum späteren Speichern an-"Checken" (Mehrfachspeichern) um ganze Zeile zum Speichern zu übernehmen'); _ ;& @CRLF & ' bzw. Rechtsklick auf SubItem um IconID für (Einzel-) Speichern zu übernehmen') Else ToolTip('Rechtsklick um IconID für (Einzel-) Speichern zu übernehmen', $aPos[0]+20, $aPos[1]+10) EndIf Else ToolTip('') EndIf So now it is not quite as flaky. But as for the general flickering, that is something I have not figured out how to solve yet. pixelsearch 1 Link to comment Share on other sites More sharing options...
AutoBert Posted August 27, 2022 Author Share Posted August 27, 2022 11 hours ago, kurtykurtyboy said: It looks like you are getting some interference with some random notification codes that you don't care about - like the "-12" when crossing the border between items. I would use $LVN_HOTTRACK for what you are trying to accomplish. Thanks, exactly what i searched. 11 hours ago, kurtykurtyboy said: No idea what is going on there, but one easy way to solve this is to use _GUICtrlListView_SubItemHitTest instead. inserting your code-snipet didn't work. But changing $NM_CLICK to $LVN_HOTTRACK in the _GUICtrlListView_SubItemHitTest Examle works, so i can check out whats needed. Link to comment Share on other sites More sharing options...
Solution AutoBert Posted August 27, 2022 Author Solution Share Posted August 27, 2022 36 minutes ago, AutoBert said: But changing $NM_CLICK to $LVN_HOTTRACK in the _GUICtrlListView_SubItemHitTest Examle works, so i can check out whats needed. I got the right idea, only reacting when realy needed: expandcollapse popupFunc WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $sIcon, $tInfo, $iIndex, $iSub, $sRes, $aPos $sDLLName = GUICtrlRead($Combo) $hWndListView = $hListview If Not IsHWnd($hListview) Then $hWndListView = GUICtrlGetHandle($hListview) $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hWndListView Switch $iCode #cs Case $LVN_COLUMNCLICK ; A column was clicked <== Diese Nachricht erreicht die Funktion nicht mehr Local $tInfo = DllStructCreate($tagNMLISTVIEW, $ilParam) ConsoleWrite('GUIRegisterMsg: $LVN_COLUMNCLICK -->Column: ' & DllStructGetData($tInfo, "SubItem") & @CRLF) #ce Case $NM_RCLICK ; Sent by a list-view control when the user clicks an item with the right mouse button $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam) $iIndex = DllStructGetData($tInfo, "Index") $iSub = DllStructGetData($tInfo, "SubItem") $sRes = _GUICtrlListView_GetItemText($hListview, $iIndex, $iSub) ConsoleWrite($iCode & @TAB & 'iIndex: ' & $iIndex & @TAB & 'iSub: ' & $iSub & @TAB & 'Text: ' & $sRes & @CRLF) If $iSub > 0 Then GUICtrlSetData($inpID, $sRes) $sIcon = @SystemDir & '\' & $sDLLName $sRes = -(1 + $sRes) ConsoleWrite($sIcon & @TAB & $sRes & @CRLF) GUICtrlSetImage($IconPreview, $sIcon, $sRes) EndIf Case $LVN_HOTTRACK $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam) $iIndex = DllStructGetData($tInfo, "Index") $iSub = DllStructGetData($tInfo, "SubItem") If ($iIndex <> -1) And (($iIndex <> $iOldIndex) Or ($iSub <> $iOldSub)) Then $sRes = _GUICtrlListView_GetItemText($hListview, $iIndex, $iSub) ConsoleWrite($iCode & @TAB & 'ItemIndex: ' & $iIndex & @TAB & 'SubIndex: ' & $iSub & @TAB & 'Text: ' & $sRes & @CRLF) $aPos = MouseGetPos() If $iSub = 0 Then ToolTip('Zum späteren Speichern an-"Checken" (Mehrfachspeichern) um ganze Zeile zum Speichern zu übernehmen', $aPos[0]) Else ToolTip('Rechtsklick um IconID für (Einzel-) Speichern zu übernehmen', $aPos[0] + 20, $aPos[1] + 10) EndIf EndIf $iOldIndex = $iIndex $iOldSub = $iSub Case $NM_KILLFOCUS ; The control has lost the input focus ToolTip('') EndSwitch Case Else ToolTip('') EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY and the flickr is away. argumentum 1 Link to comment Share on other sites More sharing options...
kurtykurtyboy Posted August 27, 2022 Share Posted August 27, 2022 I'm glad you were able to come up with a solution that worked for you! Still, it is strange that the lParam struct is still behaving strangely. Notice in this screenshot how the tooltip has already switched and it is reporting SubIndex: 0 even though my mouse is still well inside SubIndex: 1. Maybe it's just my PC.. Link to comment Share on other sites More sharing options...
kurtykurtyboy Posted August 27, 2022 Share Posted August 27, 2022 Also, sorry to nit-pick.. but it would be more proper to use $tagNMLISTVIEW instead of $tagNMITEMACTIVATE in the $LVN_HOTTRACK case. Your code works because NMITEMACTIVATE is larger, but NMLISTVIEW should be used if you want to follow the official Microsoft docs. Link to comment Share on other sites More sharing options...
AutoBert Posted August 28, 2022 Author Share Posted August 28, 2022 18 hours ago, kurtykurtyboy said: Maybe it's just my PC.. No isn't it. I set future useof _GUICtrlListView_SubItemHitTest on my TO-DO list. But as the ToolTips are just a small help and there are geater bugs it must wait. 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