rogdog Posted February 19, 2007 Share Posted February 19, 2007 I would really like to detect when the mouse is hovering over a listview item. I have managed to get single and double click events to work but have failed to get the hover function running. Here is my code CODE#include <GUIConstants.au3> ; Global constants for mousclick detection & ListView Events Global Const $WM_NOTIFY = 0x004E Global Const $NM_FIRST = 0 Global Const $NM_LAST = (-99) Global Const $NM_OUTOFMEMORY = ($NM_FIRST - 1) Global Const $NM_CLICK = ($NM_FIRST - 2) Global Const $NM_DBLCLK = ($NM_FIRST - 3) ; Global Const $NM_RETURN = ($NM_FIRST - 4) Global Const $NM_RCLICK = ($NM_FIRST - 5) ; Global Const $NM_RDBLCLK = ($NM_FIRST - 6) ; Global Const $NM_SETFOCUS = ($NM_FIRST - 7) ; Global Const $NM_KILLFOCUS = ($NM_FIRST - 8) ; Global Const $NM_CUSTOMDRAW = ($NM_FIRST - 12) Global Const $NM_HOVER = ($NM_FIRST - 13) ; Global Const $NM_NCHITTEST = ($NM_FIRST - 14) ; Global Const $NM_KEYDOWN = ($NM_FIRST - 15) ; Global Const $NM_RELEASEDCAPTURE = ($NM_FIRST - 16) ; Global Const $NM_SETCURSOR = ($NM_FIRST - 17) ; Global Const $NM_CHAR = ($NM_FIRST - 18) ; Global Const $NM_TOOLTIPSCREATED = ($NM_FIRST - 19) Global Const $LVN_FIRST = -100 Global Const $LVN_BEGINDRAG = ($LVN_FIRST - 9) Global Const $LVN_ENDDRAG = ($LVN_FIRST - 21) ;endregion End Global variables GUIRegisterMsg($WM_NOTIFY, "_WM_Notify_Events") GUICreate("listview items",220,250, 100,200,-1) $listview = GuiCtrlCreateListView ("col1|col2|col3 ",10,10,200,150);,$LVS_SORTDESCENDING) $item1=GuiCtrlCreateListViewItem("Data|Data|Data",$listview) $item2=GuiCtrlCreateListViewItem("Data|Data|Data",$listview) $item3=GuiCtrlCreateListViewItem("Data|Data|Data",$listview) $label = GUICtrlCreateLabel("Single,double or right Click any row", 10,210,230,20) GuiSetState() Do $msg = GuiGetMsg () Until $msg = $GUI_EVENT_CLOSE ;---------------------------------------------------------------------------------------------- Func _WM_Notify_Events($hWndGUI, $MsgID, $wParam, $lParam) ;---------------------------------------------------------------------------------------------- #forceref $hWndGUI, $MsgID, $wParam Local $tagNMHDR, $event, $hwndFrom, $code $tagNMHDR = DllStructCreate("int;int;int", $lParam);NMHDR (hwndFrom, idFrom, code) If @error Then Return $event = DllStructGetData($tagNMHDR, 3) if $wParam = $ListView then ;ConsoleWrite($Event&@crlf) If $event = $NM_CLICK then GUICtrlSetData($label,"Single Click detected") ; Works If $event = $NM_DBLCLK then GUICtrlSetData($label,"Double Click detected") ; Works If $event = $NM_RCLICK then GUICtrlSetData($label,"Right Click detected") ; Works If $event = $NM_HOVER then GUICtrlSetData($label,"Hover detected") ; Doesn't Work EndIf $tagNMHDR = 0 $event = 0 $lParam = 0 EndFunc ;_WM_Notify_Events Any help would be greatly appreciated My Scripts[topic="73325"]_ReverseDNS()[/topic]Favourite scripts by other members[topic="81687"]SNMP udf[/topic][topic="70759"]Using SNMP - MIB protocol[/topic][topic="39050"]_SplitMon:Section off your monitor!, split your monitor into sections for easy management[/topic][topic="73425"]ZIP.au3 UDF in pure AutoIt[/topic][topic="10534"]WMI ScriptOMatic tool for AutoIt[/topic][topic="51103"]Resources UDF embed/use any data/files into/from AutoIt compiled EXE files[/topic] Link to comment Share on other sites More sharing options...
GaryFrost Posted February 19, 2007 Share Posted February 19, 2007 expandcollapse popup#include <GUIConstants.au3> ; Global constants for mousclick detection & ListView Events Global Const $WM_NOTIFY = 0x004E Global Const $NM_FIRST = 0 Global Const $NM_LAST = (-99) Global Const $NM_OUTOFMEMORY = ($NM_FIRST - 1) Global Const $NM_CLICK = ($NM_FIRST - 2) Global Const $NM_DBLCLK = ($NM_FIRST - 3) ; Global Const $NM_RETURN = ($NM_FIRST - 4) Global Const $NM_RCLICK = ($NM_FIRST - 5) ; Global Const $NM_RDBLCLK = ($NM_FIRST - 6) ; Global Const $NM_SETFOCUS = ($NM_FIRST - 7) ; Global Const $NM_KILLFOCUS = ($NM_FIRST - 8) ; Global Const $NM_CUSTOMDRAW = ($NM_FIRST - 12) Global Const $NM_HOVER = ($NM_FIRST - 13) ; Global Const $NM_NCHITTEST = ($NM_FIRST - 14) ; Global Const $NM_KEYDOWN = ($NM_FIRST - 15) ; Global Const $NM_RELEASEDCAPTURE = ($NM_FIRST - 16) ; Global Const $NM_SETCURSOR = ($NM_FIRST - 17) ; Global Const $NM_CHAR = ($NM_FIRST - 18) ; Global Const $NM_TOOLTIPSCREATED = ($NM_FIRST - 19) Global Const $LVN_FIRST = -100 Global Const $LVN_BEGINDRAG = ($LVN_FIRST - 9) Global Const $LVN_ENDDRAG = ($LVN_FIRST - 21) ;endregion End Global variables GUIRegisterMsg($WM_NOTIFY, "_WM_Notify_Events") GUICreate("listview items", 220, 250, 100, 200, -1) $listview = GUICtrlCreateListView("col1|col2|col3 ", 10, 10, 200, 150);,$LVS_SORTDESCENDING) GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_TRACKSELECT, $LVS_EX_TRACKSELECT) $item1 = GUICtrlCreateListViewItem("Data|Data|Data", $listview) $item2 = GUICtrlCreateListViewItem("Data|Data|Data", $listview) $item3 = GUICtrlCreateListViewItem("Data|Data|Data", $listview) $label = GUICtrlCreateLabel("Single,double or right Click any row", 10, 210, 230, 20) GUISetState() Do $msg = GUIGetMsg() Until $msg = $GUI_EVENT_CLOSE ;---------------------------------------------------------------------------------------------- Func _WM_Notify_Events($hWndGUI, $MsgID, $wParam, $lParam) ;---------------------------------------------------------------------------------------------- #forceref $hWndGUI, $MsgID, $wParam Local $tagNMHDR, $event, $hwndFrom, $code $tagNMHDR = DllStructCreate("int;int;int", $lParam);NMHDR (hwndFrom, idFrom, code) If @error Then Return $event = DllStructGetData($tagNMHDR, 3) If $wParam = $listview Then ;ConsoleWrite($Event&@crlf) If $event = $NM_CLICK Then GUICtrlSetData($label, "Single Click detected") ; Works If $event = $NM_DBLCLK Then GUICtrlSetData($label, "Double Click detected") ; Works If $event = $NM_RCLICK Then GUICtrlSetData($label, "Right Click detected") ; Works If $event = $NM_HOVER Then GUICtrlSetData($label, "Hover detected") ; Doesn't Work EndIf $tagNMHDR = 0 $event = 0 $lParam = 0 EndFunc ;==>_WM_Notify_Events 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 More sharing options...
rogdog Posted February 19, 2007 Author Share Posted February 19, 2007 Yet again you come to the rescue. Many thanks My Scripts[topic="73325"]_ReverseDNS()[/topic]Favourite scripts by other members[topic="81687"]SNMP udf[/topic][topic="70759"]Using SNMP - MIB protocol[/topic][topic="39050"]_SplitMon:Section off your monitor!, split your monitor into sections for easy management[/topic][topic="73425"]ZIP.au3 UDF in pure AutoIt[/topic][topic="10534"]WMI ScriptOMatic tool for AutoIt[/topic][topic="51103"]Resources UDF embed/use any data/files into/from AutoIt compiled EXE files[/topic] Link to comment Share on other sites More sharing options...
rogdog Posted February 19, 2007 Author Share Posted February 19, 2007 Is there any way to make it so that the row is not selected when the hover occurs ? I have tried using $LVS_EX_INFOTIP instaed of $LVS_EX_TRACKSELECT but can't get it to work My Scripts[topic="73325"]_ReverseDNS()[/topic]Favourite scripts by other members[topic="81687"]SNMP udf[/topic][topic="70759"]Using SNMP - MIB protocol[/topic][topic="39050"]_SplitMon:Section off your monitor!, split your monitor into sections for easy management[/topic][topic="73425"]ZIP.au3 UDF in pure AutoIt[/topic][topic="10534"]WMI ScriptOMatic tool for AutoIt[/topic][topic="51103"]Resources UDF embed/use any data/files into/from AutoIt compiled EXE files[/topic] Link to comment Share on other sites More sharing options...
GaryFrost Posted February 19, 2007 Share Posted February 19, 2007 expandcollapse popup#include <GUIConstants.au3> ; Global constants for mousclick detection & ListView Events Global Const $WM_NOTIFY = 0x004E Global Const $NM_FIRST = 0 Global Const $NM_LAST = (-99) Global Const $NM_OUTOFMEMORY = ($NM_FIRST - 1) Global Const $NM_CLICK = ($NM_FIRST - 2) Global Const $NM_DBLCLK = ($NM_FIRST - 3) ; Global Const $NM_RETURN = ($NM_FIRST - 4) Global Const $NM_RCLICK = ($NM_FIRST - 5) ; Global Const $NM_RDBLCLK = ($NM_FIRST - 6) ; Global Const $NM_SETFOCUS = ($NM_FIRST - 7) ; Global Const $NM_KILLFOCUS = ($NM_FIRST - 8) ; Global Const $NM_CUSTOMDRAW = ($NM_FIRST - 12) Global Const $NM_HOVER = ($NM_FIRST - 13) ; Global Const $NM_NCHITTEST = ($NM_FIRST - 14) ; Global Const $NM_KEYDOWN = ($NM_FIRST - 15) ; Global Const $NM_RELEASEDCAPTURE = ($NM_FIRST - 16) ; Global Const $NM_SETCURSOR = ($NM_FIRST - 17) ; Global Const $NM_CHAR = ($NM_FIRST - 18) ; Global Const $NM_TOOLTIPSCREATED = ($NM_FIRST - 19) Global Const $LVN_FIRST = -100 Global Const $LVN_HOTTRACK = ($LVN_FIRST - 21) ;endregion End Global variables GUIRegisterMsg($WM_NOTIFY, "_WM_Notify_Events") GUICreate("listview items", 220, 250, 100, 200, -1) $listview = GUICtrlCreateListView("col1|col2|col3 ", 10, 10, 200, 150);,$LVS_SORTDESCENDING) ;~ GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_TRACKSELECT, $LVS_EX_TRACKSELECT) GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_ONECLICKACTIVATE, $LVS_EX_ONECLICKACTIVATE) $item1 = GUICtrlCreateListViewItem("Data|Data|Data", $listview) $item2 = GUICtrlCreateListViewItem("Data|Data|Data", $listview) $item3 = GUICtrlCreateListViewItem("Data|Data|Data", $listview) $label = GUICtrlCreateLabel("Single,double or right Click any row", 10, 210, 230, 20) GUISetState() Do $msg = GUIGetMsg() Until $msg = $GUI_EVENT_CLOSE ;---------------------------------------------------------------------------------------------- Func _WM_Notify_Events($hWndGUI, $MsgID, $wParam, $lParam) ;---------------------------------------------------------------------------------------------- #forceref $hWndGUI, $MsgID, $wParam Local $tagNMHDR, $event, $hwndFrom, $code, $tagNMLISTVIEW $tagNMHDR = DllStructCreate("int;int;int", $lParam);NMHDR (hwndFrom, idFrom, code) If @error Then Return $event = DllStructGetData($tagNMHDR, 3) If $wParam = $listview Then Switch $event Case $NM_CLICK GUICtrlSetData($label, "Single Click detected") Case $NM_DBLCLK GUICtrlSetData($label, "Double Click detected") Case $NM_RCLICK GUICtrlSetData($label, "Right Click detected") Case $NM_HOVER GUICtrlSetData($label, "Hover detected") Case $LVN_HOTTRACK $tagNMLISTVIEW = DllStructCreate("int;int;int;int;int;uint;uint;uint;int;int", $lParam) If DllStructGetData($tagNMLISTVIEW,4) > -1 Then GUICtrlSetData($label, "Hot Track: " & DllStructGetData($tagNMLISTVIEW,4)) EndSwitch EndIf $tagNMHDR = 0 $event = 0 $lParam = 0 EndFunc ;==>_WM_Notify_Events 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 More sharing options...
rogdog Posted February 19, 2007 Author Share Posted February 19, 2007 Thanks Gary My Scripts[topic="73325"]_ReverseDNS()[/topic]Favourite scripts by other members[topic="81687"]SNMP udf[/topic][topic="70759"]Using SNMP - MIB protocol[/topic][topic="39050"]_SplitMon:Section off your monitor!, split your monitor into sections for easy management[/topic][topic="73425"]ZIP.au3 UDF in pure AutoIt[/topic][topic="10534"]WMI ScriptOMatic tool for AutoIt[/topic][topic="51103"]Resources UDF embed/use any data/files into/from AutoIt compiled EXE files[/topic] 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