PartyPooper Posted November 22, 2009 Share Posted November 22, 2009 I'm trying to set tips for individual items in a listview, however, I'm not having much success. I was hoping that the individual tips would display as the cursor hovered over each item, but it doesn't seem to work (see code for example). Does anyone know if it's even possible to do? #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Include <GuiListView.au3> Opt('MustDeclareVars', 1) Example() Func Example() Local $listview, $item1, $item2, $item3, $msg GUICreate("listview items", 220, 250, 100, 200, -1, $WS_EX_ACCEPTFILES) GUISetBkColor(0x00E0FFFF) ; will change background color $listview = GUICtrlCreateListView("col1|col2|col3", 10, 10, 200, 150,BitOR($LVS_REPORT, $LVS_SHOWSELALWAYS, $LVS_SINGLESEL), $WS_EX_CLIENTEDGE) _GUICtrlListView_SetExtendedListViewStyle($listview, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_TRACKSELECT, $LVS_EX_UNDERLINEHOT, $LVS_EX_DOUBLEBUFFER)) $item1 = GUICtrlCreateListViewItem("item1|stuff|stuff", $listview) GUICtrlSetTip($item1,"item1") $item2 = GUICtrlCreateListViewItem("item2|stuff|stuff", $listview) GUICtrlSetTip($item2,"item2") $item3 = GUICtrlCreateListViewItem("item3|stuff|stuff", $listview) GUICtrlSetTip($item3,"item3") GUISetState() Do $msg = GUIGetMsg() Select Case $msg = $listview MsgBox(0, "listview", "clicked=" & GUICtrlGetState($listview), 2) EndSelect Until $msg = $GUI_EVENT_CLOSE EndFunc ;==>Example Link to comment Share on other sites More sharing options...
water Posted November 22, 2009 Share Posted November 22, 2009 I searched the forum and found the following post.Insert #include <WindowsConstants.au3>and it runs just fine. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
picaxe Posted November 22, 2009 Share Posted November 22, 2009 (edited) expandcollapse popup; by picaxe #include <GuiConstantsEx.au3> #include <GuiListView.au3> #include <GuiStatusBar.au3> #include <WindowsConstants.au3> Global $hListView, $hStatus Global $aToolTipText[16][3] = [["First tooltip", "", "Second tooltip"],["Third tooltip", "Fourth tooltip", ""], _ ["", "", ""],["", "", ""],["", "", ""],["", "Fifth tooltip", ""],["", "", "Sixth tooltip"], _ ["", "", ""],["", "", ""],["", "", ""],["", "Seventh tooltip", ""]] Local $hGUI = GUICreate("ListView Hover Tooltips", 395, 320) $hListView = GUICtrlCreateListView("", 5, 5, 385, 290) $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() _GUICtrlListView_AddColumn($hListView, "Column 1", 100) _GUICtrlListView_AddColumn($hListView, "Column 2", 100) _GUICtrlListView_AddColumn($hListView, "Column 3", 100) For $i = 0 To 15 $j = "Row " & StringFormat("%.02u", $i) _GUICtrlListView_AddItem($hListView, $j & ": Col 1") _GUICtrlListView_AddSubItem($hListView, $i, $j & ": Col 2", 1) _GUICtrlListView_AddSubItem($hListView, $i, $j & ": Col 3", 2) Next GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") Do Sleep(20) Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() Exit Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hListView Switch $iCode Case $LVN_HOTTRACK Local $tInfo = DllStructCreate($tagNMLISTVIEW, $ilParam) Local $iItem = DllStructGetData($tInfo, "Item"), $iSubItem = DllStructGetData($tInfo, "SubItem") If Not ($iItem = -1 Or $iSubItem = -1) Then _GUICtrlStatusBar_SetText($hStatus, "Item: " & $iItem & " SubItem: " & $iSubItem) If $aToolTipText[$iItem][$iSubItem] <> "" Then ToolTip($aToolTipText[$iItem][$iSubItem]) Else ToolTip("") EndIf Else _GUICtrlStatusBar_SetText($hStatus, "") ToolTip("") EndIf EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY Edit: correct spelling Edited November 22, 2009 by picaxe Link to comment Share on other sites More sharing options...
PartyPooper Posted November 22, 2009 Author Share Posted November 22, 2009 I searched the forum and found the following post. Insert #include <WindowsConstants.au3>and it runs just fine. Thanks water but it's not quite what I'm after (the tooltips in this case form part of the listview item text which is not what I want). It has given me something else to look at though :-) Link to comment Share on other sites More sharing options...
PartyPooper Posted November 22, 2009 Author Share Posted November 22, 2009 ...Thanks picaxe, this is what I'm after although it's somewhat more complicated than I hoped but it has given me a start point. Cheers. 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