matwachich Posted December 17, 2012 Posted December 17, 2012 Hello guys! I've got a simple question: - Is it possible to display a ToolTip on ListBox Item? - I want to display it when an Item is too long for the ListBox width, and a part of it is hidden (Just like a ListView does, but for a ListBox) Thanks!
Malkey Posted December 18, 2012 Posted December 18, 2012 Here is an attempt at having tool tips on the long list box items. expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Example() Func Example() Local $MESSAGE = "The following buttons have been clicked.|line 3." Local $add, $clear, $mylist, $close, $msg, $tt = 0 Local $iListBoxWidth = 23 ; Number of characters that will fit in lost box width. Static $iNum = 1 Local $hGui = GUICreate("My GUI list") ; will create a dialog box that when displayed is centered $add = GUICtrlCreateButton("Add", 64, 32, 75, 25) $clear = GUICtrlCreateButton("Clear", 64, 72, 75, 25) $mylist = GUICtrlCreateList("buttons that have been clicked", 176, 32, 143, 97, BitOR($WS_BORDER, $WS_VSCROLL)) GUICtrlSetLimit(-1, 200) ; to limit horizontal scrolling GUICtrlSetData(-1, $MESSAGE) $close = GUICtrlCreateButton("my closing button", 64, 160, 175, 25) GUISetState() $msg = 0 While $msg <> -3 ; $GUI_EVENT_CLOSE $msg = GUIGetMsg() $aCI = GUIGetCursorInfo($hGui) If $tt = 1 And $aCI[4] <> $mylist Then $tt = 0 ToolTip("") EndIf Select Case $msg = $add GUICtrlSetData($mylist, "Add button clicked No" & $iNum) $iNum += 1 Case $msg = $clear GUICtrlSetData($mylist, "") Case $msg = $close MsgBox(0, "", "the closing button has been clicked", 2) Exit Case $msg = $mylist If StringLen(GUICtrlRead($mylist)) > $iListBoxWidth Then ToolTip(GUICtrlRead($mylist)) $tt = 1 Else ToolTip("") $tt = 0 EndIf EndSelect WEnd EndFunc ;==>Example
matwachich Posted December 18, 2012 Author Posted December 18, 2012 Thanks for the answer. But it's not really what i'm looking for. I want the toolTips to display when i hover the long item, because the clique event is already used. Thanks
Malkey Posted December 19, 2012 Posted December 19, 2012 Here is an example at having a tool tip appear when hovering over a long, list box item. expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiListBox.au3> #include <GUIConstantsEx.au3> Example() Func Example() Local $MESSAGE = "The following buttons have been clicked.|line 3." Local $add, $clear, $mylist, $close, $msg ; --- Variables for Tool Tip Hover --- Local $aCI, $iIndex, $sText, $tt = 0 Local $iListBoxWidth = 23 ; Number of characters that will fit in lost box width. ; ------------------------------------- Local $iNum = 1 Local $hGui = GUICreate("My GUI list") ; will create a dialog box that when displayed is centered $add = GUICtrlCreateButton("Add", 64, 32, 75, 25) $clear = GUICtrlCreateButton("Clear", 64, 72, 75, 25) $mylist = GUICtrlCreateList("buttons that have been clicked", 176, 32, 143, 97, BitOR($WS_BORDER, $WS_VSCROLL)) GUICtrlSetLimit(-1, 200) ; to limit horizontal scrolling GUICtrlSetData(-1, $MESSAGE) $close = GUICtrlCreateButton("my closing button", 64, 160, 175, 25) GUISetState() $msg = 0 While $msg <> -3 ; $GUI_EVENT_CLOSE ;--- Tool Tip when hover over list box item with greater than '$iListBoxWidth' characters --- $aCI = GUIGetCursorInfo($hGui) If $aCI[4] = $mylist Then $iIndex = _GUICtrlListBox_ItemFromPoint($mylist, $aCI[0] - 176, $aCI[1] - 32) $sText = _GUICtrlListBox_GetText($mylist, $iIndex) If StringLen($sText) > $iListBoxWidth Then ToolTip($sText) $tt = 1 Else ToolTip("") $tt = 0 EndIf EndIf If $tt = 1 And $aCI[4] <> $mylist Then $tt = 0 ToolTip("") EndIf ; -------- End of Tool Tip Hover --------------- $msg = GUIGetMsg() Select Case $msg = $add GUICtrlSetData($mylist, "Add button clicked No" & $iNum) $iNum += 1 Case $msg = $clear GUICtrlSetData($mylist, "") Case $msg = $close MsgBox(0, "", "the closing button has been clicked", 2) Exit EndSelect WEnd EndFunc ;==>Example
AZJIO Posted January 4, 2013 Posted January 4, 2013 (edited) Tip in item position expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiListBox.au3> Example() Func Example() Local $MESSAGE = "The following buttons have been clicked.|line 3." Local $add, $clear, $mylist, $close, $msg, $aRect, $tRect, $iTmpMouseY, $hListBox ; --- Variables for Tool Tip Hover --- Local $aCI, $iIndex, $sText, $tt = 0 Local $iListBoxWidth = 23 ; Number of characters that will fit in lost box width. ; ------------------------------------- Local $iNum = 1 Local $hGui = GUICreate("My GUI list") ; will create a dialog box that when displayed is centered $add = GUICtrlCreateButton("Add", 64, 32, 75, 25) $clear = GUICtrlCreateButton("Clear", 64, 72, 75, 25) $mylist = GUICtrlCreateList("buttons that have been clicked", 176, 32, 143, 97, BitOR($WS_BORDER, $WS_VSCROLL)) GUICtrlSetLimit(-1, 200) ; to limit horizontal scrolling GUICtrlSetData(-1, $MESSAGE) $hListBox = GUICtrlGetHandle(-1) $close = GUICtrlCreateButton("my closing button", 64, 160, 175, 25) GUISetState() While 1 ;--- Tool Tip when hover over list box item with greater than '$iListBoxWidth' characters --- $aCI = GUIGetCursorInfo($hGui) If $aCI[4] = $mylist And $iTmpMouseY <> $aCI[1] Then $iTmpMouseY = $aCI[1] $iIndex = _GUICtrlListBox_ItemFromPoint($hListBox, $aCI[0] - 176, $aCI[1] - 32) $sText = _GUICtrlListBox_GetText($hListBox, $iIndex) If StringLen($sText) > $iListBoxWidth Then $aRect = _GUICtrlListBox_GetItemRect($hListBox, $iIndex) $tRect = _WinAPI_GetWindowRect($hListBox) ToolTip($sText, $aRect[0] + DllStructGetData($tRect, "Left"), $aRect[3] + 3 + DllStructGetData($tRect, "Top")) $tt = 1 Else ToolTip("") $tt = 0 EndIf EndIf If $tt = 1 And $aCI[4] <> $mylist Then $tt = 0 ToolTip("") EndIf ; -------- End of Tool Tip Hover --------------- $msg = GUIGetMsg() Switch $msg Case $add GUICtrlSetData($mylist, "121221367456 Add button clicked No" & $iNum) Case $clear GUICtrlSetData($mylist, "") Case $close MsgBox(0, "", "the closing button has been clicked", 2) Exit Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd EndFunc ;==>Example Edited January 4, 2013 by AZJIO My other projects or all
TrickyDeath Posted July 17, 2014 Posted July 17, 2014 First of all sorry for "necro" post! I just do not wanted to make a new topic with nearly same question, what was solved here. My question is the same as the original topic maker, but with TreeView. Does it posible to put a tooltip on all TreeView item? (like a short description on them) or better to make a little memo next to the TreeView and write there the description for the selected element? Sry for my bad English, and double sry, but I am learning AutoIT language by myself. :) [u]Tricky[/u] You can't teach a man anything, you can only help him, find it within himself. (Galileo Galilei)
Moderators Melba23 Posted July 17, 2014 Moderators Posted July 17, 2014 TrickyDeath, My question is the same as the original topicNo it is not - it is about a completely different control. So please start a new thread and do not hijack this one. 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
Recommended Posts