schliden Posted May 21, 2007 Share Posted May 21, 2007 I have a ListView control with 5 columns: 1. A Checkbox (to enable/disable selection) 2. A Count 3. A Source 4. A Target 5. A Status I have used the following code: CODE; global constant to support ListView events Global Const $WM_NOTIFY = 0x004E ;ListView Events Global Const $NM_FIRST = 0 - 0 Global Const $NM_LAST = 0 - 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 ;Register user defined function "exEvents" for known Windows Messages $WM_NOTIFY (use to trap double click in ListView) GUIRegisterMsg($WM_NOTIFY, "exEvents") .... ;------------------------------------------------------------------------ ; Description: $WM_NOTIFY event handler ;------------------------------------------------------------------------ Func exEvents($hWndGUI, $MsgID, $WParam, $LParam) Switch $WParam Case $ListView1 $tagNMHDR = DllStructCreate ( "int;int;int",$LParam) ;NMHDR (hwndFrom, idFrom, code) $code = DllStructGetData ( $tagNMHDR, 3) Switch $code Case $NM_DBLCLK _EditListItem($ListView1,$cListColTarget) Case $NM_HOVER _HoverListItem($ListView1,$cListColSource) Endswitch Endswitch endfunc to allow doubleclick handling. (I don't know if this is the correct way, but it seems to work) I am, however, unable to detect the specific column that is double-clicked. Is it possible to detect which column is double-clicked ? ________________________ Also, I don't seem to be able to get Case $NM_HOVER to work ? What I would like to do is display a tooltip that expands the full text of the item in the listbox onmouseover. TIA Link to comment Share on other sites More sharing options...
GaryFrost Posted May 21, 2007 Share Posted May 21, 2007 expandcollapse popup; Events - ListView #include <GuiConstants.au3>;Inclusion file for the GUI interface controls #include <GuiListView.au3> Global $ListView Global Const $WM_NOTIFY = 0x004E Global Const $DebugIt = 1 ;ListView Events 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) #endregion End Global variables Opt("WinTitleMatchMode", 2) $main_GUI = GUICreate("GuiRegisterMsg Test", 225, 400, 300, 10, BitOR($WS_THICKFRAME, $WS_SIZEBOX)) $ListView = GUICtrlCreateListView("Entry Name|Category", 5, 75, 195, 280, BitOR($LVS_SORTASCENDING, $LVS_SINGLESEL)) _GUICtrlListViewSetColumnWidth ($ListView, 0, 100) _GUICtrlListViewSetColumnWidth ($ListView, 1, 100) GUICtrlSendMsg($ListView, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES) GUICtrlSendMsg($ListView, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_FULLROWSELECT, $LVS_EX_FULLROWSELECT) GUICtrlCreateListViewItem("Name 1|Category 1", $ListView) GUICtrlCreateListViewItem("Name 2|Category 2", $ListView) GUISetState() ;Register WM_NOTIFY events GUIRegisterMsg($WM_NOTIFY, "WM_Notify_Events") While 1 $msg = GUIGetMsg() Switch $msg ;----------------------------------------------------------------------------------------- ;This case statement exits and updates code if needed Case $GUI_EVENT_CLOSE Exit ;----------------------------------------------------------------------------------------- ;put all the misc. stuff here Case Else ;;; EndSwitch WEnd Func ListView_Click() ;---------------------------------------------------------------------------------------------- If $DebugIt Then _DebugPrint ("$NM_CLICK") ;---------------------------------------------------------------------------------------------- EndFunc ;==>ListView_Click Func ListView_DoubleClick() ;---------------------------------------------------------------------------------------------- If $DebugIt Then _DebugPrint ("$NM_DBLCLK") ;---------------------------------------------------------------------------------------------- MsgBox(0,"Double Clicked", _GUICtrlListViewGetItemText ($ListView, _GUICtrlListViewGetSelectedIndices($ListView))) EndFunc ;==>ListView_DoubleClick ; ; WM_NOTIFY event handler Func WM_Notify_Events($hWndGUI, $MsgID, $wParam, $lParam) #forceref $hWndGUI, $MsgID, $wParam Local $tagNMLISTVIEW , $event, $hwndFrom, $code $tagNMLISTVIEW = DllStructCreate("int;int;int;int;int;uint;uint;uint;int;int", $lParam) ;NMHDR (hwndFrom, idFrom, code), (iItem, iSubItem, uNewState, uOldState, uChanged, ptAction) If @error Then Return $event = DllStructGetData($tagNMLISTVIEW, 3) Switch $wParam Case $ListView Switch $event Case $NM_CLICK _DebugPrint("Item: " & DllStructGetData($tagNMLISTVIEW,4) & " SubItem: " & DllStructGetData($tagNMLISTVIEW,5)) ListView_Click () Case $NM_DBLCLK ListView_DoubleClick () EndSwitch EndSwitch $tagNMHDR = 0 $event = 0 $lParam = 0 EndFunc ;==>WM_Notify_Events Func _DebugPrint($s_text) $s_text = StringReplace($s_text, @LF, @LF & "-->") ConsoleWrite("!===========================================================" & @LF & _ "+===========================================================" & @LF & _ "-->" & $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 More sharing options...
schliden Posted May 21, 2007 Author Share Posted May 21, 2007 Thanks (ga)ry ? Is it possible to pickup the mouseover event ? TIA Link to comment Share on other sites More sharing options...
birdofprey Posted May 21, 2007 Share Posted May 21, 2007 Thanks (ga)ry ? Is it possible to pickup the mouseover event ? TIA uncomment this:;~ Global Const $NM_HOVER = ($NM_FIRST - 13)oÝ÷ Ù©Ýi×Z)ÞêÞ)¶¬jëh×6 Case $ListView Switch $event Case $NM_CLICK _DebugPrint("Item: " & DllStructGetData($tagNMLISTVIEW,4) & " SubItem: " & DllStructGetData($tagNMLISTVIEW,5)) ListView_Click () Case $NM_DBLCLK ListView_DoubleClick () Case $NM_HOVER ListView_MouseOver () EndSwitch ...and create this ListView_MouseOver () function so that something actually happens. Link to comment Share on other sites More sharing options...
schliden Posted May 21, 2007 Author Share Posted May 21, 2007 uncomment this:;~ Global Const $NM_HOVER = ($NM_FIRST - 13)oÝ÷ Ù©Ýi×Z)ÞêÞ)¶¬jëh×6 Case $ListView Switch $event Case $NM_CLICK _DebugPrint("Item: " & DllStructGetData($tagNMLISTVIEW,4) & " SubItem: " & DllStructGetData($tagNMLISTVIEW,5)) ListView_Click () Case $NM_DBLCLK ListView_DoubleClick () Case $NM_HOVER ListView_MouseOver () EndSwitch ...and create this ListView_MouseOver () function so that something actually happens. Thanks... I found that I also needed to do this: GUICtrlSendMsg($ListView1, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_TRACKSELECT, $LVS_EX_TRACKSELECT) Although the tooltip now works, it seems to prevent the $NM_DBLCLK from working. Link to comment Share on other sites More sharing options...
schliden Posted May 21, 2007 Author Share Posted May 21, 2007 Thanks...I found that I also needed to do this:GUICtrlSendMsg($ListView1, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_TRACKSELECT, $LVS_EX_TRACKSELECT)Although the tooltip now works, it seems to prevent the $NM_DBLCLK from working.Ahhh, fixed the blocking with:; set the time required before a hover event fires_GUICtrlListViewSetHoverTime($ListView1,2000) 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