supersonic Posted June 1, 2015 Posted June 1, 2015 (edited) Hi -I've found an older post from doudou on this topic in example section - but I can't get this working...Please, could someone enlight me? I'm not able to solve it on my own... :-( Edited June 1, 2015 by supersonic
Moderators Melba23 Posted June 1, 2015 Moderators Posted June 1, 2015 supersonic,Why not use the standard GUIToolTip UDF to do it? Here is a modified version of the _GUIToolTip_Create example in the Help file which has different tooltips on the header and body of the ListView:expandcollapse popup#include <GUIConstantsEx.au3> #include <GUIToolTip.au3> #include <GuiListView.au3> Example() Func Example() Local $hGUI = GUICreate(StringTrimRight(@ScriptName, StringLen(".exe")), 270, 200) Local $idButton = GUICtrlCreateButton("Add", 30, 32, 75, 25) Local $hButton = GUICtrlGetHandle($idButton) Local $idClear = GUICtrlCreateButton("Clear", 30, 72, 75, 25) Local $hClear = GUICtrlGetHandle($idClear) Local $idMyListView = GUICtrlCreateListView("Item 1", 120, 32, 121, 97) Local $hMyListView = GUICtrlGetHandle($idMyListView) Local $hMyHeader = _GUICtrlListView_GetHeader($hMyListView) ; <<<<<<<<<<< GUICtrlCreateListViewItem("Item 1", $idMyListView) Local $idClose = GUICtrlCreateButton("Exit button", 80, 150, 110, 28) Local $hClose = GUICtrlGetHandle($idClose) ; Create 2 tooltip controls Local $hToolTip1 = _GUIToolTip_Create(0, BitOR($_TT_ghTTDefaultStyle, $TTS_BALLOON)); balloon style tooltip Local $hToolTip2 = _GUIToolTip_Create(0) ; default style tooltip _GUIToolTip_SetMaxTipWidth($hToolTip2, 100) ; this allows multiline tooltips to be used with $hToolTip2 ; add tools to the tooltip controls _GUIToolTip_AddTool($hToolTip1, 0, "Adds an item to the list", $hButton) _GUIToolTip_AddTool($hToolTip1, 0, "Exit the script", $hClose) _GUIToolTip_AddTool($hToolTip1, 0, "The listview header", $hMyHeader) ; <<<<<<<<<<<<<<<< _GUIToolTip_AddTool($hToolTip2, 0, "The listview", $hMyListView) _GUIToolTip_AddTool($hToolTip2, 0, "Clears the list", $hClear) _GUIToolTip_AddTool($hToolTip2, 0, "Multiline tooltip" & @CRLF & "for the GUI", $hGUI) ; Multiline ToolTip GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $idButton GUICtrlSetData($idMyListView, 'The Add button was pressed"|') Case $idClear GUICtrlSetData($idMyListView, '') Case $idClose, $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd ; Destroy the tooltip controls _GUIToolTip_Destroy($hToolTip1) _GUIToolTip_Destroy($hToolTip2) GUIDelete($hGUI) EndFunc ;==>ExampleM23 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
supersonic Posted June 1, 2015 Author Posted June 1, 2015 M23,thank you.I was not precise enough: How to set a separate tooltip for each column header?
Moderators Melba23 Posted June 1, 2015 Moderators Posted June 1, 2015 supersonic,Then you need to do something like this:expandcollapse popup#include <GUIConstantsEx.au3> #include <GUIToolTip.au3> #include <GuiListView.au3> #include <WinAPI.au3> #include <Array.au3> $hGUI = GUICreate("Test", 500, 500) $cLV = GUICtrlCreateListView("Column 0|Column 1|Column 2", 10, 10, 300, 300) $hHeader = _GUICtrlListView_GetHeader($cLV) GUICtrlCreateListViewItem("Item 1", $cLV) $hToolTip = _GUIToolTip_Create(0, BitOR($_TT_ghTTDefaultStyle, $TTS_BALLOON)); balloon style tooltip _GUIToolTip_AddTool($hToolTip, 0, "LV Header", $hHeader) GUISetState(@SW_SHOW) ; gte array with column right side posiitons Global $aCol_Pos[3] For $i = 0 To 2 $aCol_Pos[$i] = _GUICtrlListView_GetColumnWidth($cLV, $i) If $i > 0 Then $aCol_Pos[$i] += $aCol_Pos[$i - 1] EndIf Next ; Just for display _ArrayDisplay($aCol_Pos, "", Default, 8) Global $tPoint = DllStructCreate($tagPOINT) Global $iCol = -1 While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch _UpDate_Header_Tool() WEnd _GUIToolTip_Destroy($hToolTip) Func _UpDate_Header_Tool() ; Get mouse position $aMPos = MouseGetPos() DllStructSetData($tPoint, "x", $aMPos[0]) DllStructSetData($tPoint, "y", $aMPos[1]) ; Check if over header $hHandle = _WinAPI_WindowFromPoint($tPoint) If $hHandle = $hHeader Then ; Get header position $aHPos = WinGetPos($hHeader) ; Check column under cursor For $i = 0 To 2 If $aMPos[0] - $aHPos[0] < $aCol_Pos[$i] Then ; if column has changed If $i <> $iCol Then ; Update tooltip text _GUIToolTip_UpdateTipText($hToolTip, 0, $hHeader, "Column " & $i ) $iCol = $i EndIf ExitLoop EndIf Next EndIf EndFuncYou could always run the function only when the mouse moves if you wanted to be more elegant, but I have my hands full with Korean spammers at the moment.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
supersonic Posted June 2, 2015 Author Posted June 2, 2015 (edited) M23,I embedded your code into my script. Works so far. But if any column is resized the col. widths in '$aCol_Pos' will become incorrect. Is there a WM_NOTIFY trigger for LV col. resizing? Edited June 2, 2015 by supersonic
Moderators Melba23 Posted June 2, 2015 Moderators Posted June 2, 2015 supersonic,Is there a WM_NOTIFY trigger for LV col. resizing?Of course - have you done any research to see what it might be?expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GUIToolTip.au3> #include <GuiListView.au3> #include <HeaderConstants.au3> #include <WinAPI.au3> #include <Array.au3> Global $bCols_Resize = False, $aCol_Pos[3] $hGUI = GUICreate("Test", 500, 500) $cLV = GUICtrlCreateListView("Column 0|Column 1|Column 2", 10, 10, 300, 300) $hHeader = _GUICtrlListView_GetHeader($cLV) GUICtrlCreateListViewItem("Item 1", $cLV) $hToolTip = _GUIToolTip_Create(0, BitOR($_TT_ghTTDefaultStyle, $TTS_BALLOON)); balloon style tooltip _GUIToolTip_AddTool($hToolTip, 0, "LV Header", $hHeader) GUISetState(@SW_SHOW) _Size_Cols() Global $tPoint = DllStructCreate($tagPOINT) Global $iCol = -1 GUIRegisterMsg($WM_NOTIFY, "_WM_NOTIFY") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch ; Have cols been resized? If $bCols_Resize Then $bCols_Resize = False _Size_Cols() EndIf ; Check if header tootip required and set correct text _UpDate_Header_Tool() WEnd _GUIToolTip_Destroy($hToolTip) Func _WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) ; Get details of message Local $tNMHEADER = DllStructCreate($tagNMHEADER, $lParam) ; Look for end of header resize code $iCode = DllStructGetData($tNMHEADER, "Code") Switch $iCode Case $HDN_ENDTRACKW ; Set flag $bCols_Resize = True EndSwitch EndFunc ;==>_WM_NOTIFY Func _Size_Cols() ; Get array with column right side posiitons For $i = 0 To 2 $aCol_Pos[$i] = _GUICtrlListView_GetColumnWidth($cLV, $i) If $i > 0 Then $aCol_Pos[$i] += $aCol_Pos[$i - 1] EndIf Next ; Just for display _ArrayDisplay($aCol_Pos, "", Default, 8) EndFunc ;==>_Size_Cols Func _UpDate_Header_Tool() ; Get mouse position $aMPos = MouseGetPos() DllStructSetData($tPoint, "x", $aMPos[0]) DllStructSetData($tPoint, "y", $aMPos[1]) ; Check if over header $hHandle = _WinAPI_WindowFromPoint($tPoint) If $hHandle = $hHeader Then ; Get header position $aHPos = WinGetPos($hHeader) ; Check column under cursor For $i = 0 To 2 If $aMPos[0] - $aHPos[0] < $aCol_Pos[$i] Then ; if column has changed If $i <> $iCol Then ; Update tooltip text _GUIToolTip_UpdateTipText($hToolTip, 0, $hHeader, "Column " & $i) $iCol = $i EndIf ExitLoop EndIf Next EndIf EndFunc ;==>_UpDate_Header_ToolM23 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
supersonic Posted June 2, 2015 Author Posted June 2, 2015 Yes, Sir, I have! For '$iCode' I get '-12', so I call '_UpDate_Header_Tool()' to refresh pos. array. Furthermore I've implemented your LV header tooltip code for more than one LV.Thank you... Again!
Moderators Melba23 Posted June 2, 2015 Moderators Posted June 2, 2015 supersonic,Well done. If you did not realise - you will see that there is some code inside the top spoiler of my last post which shows another way of doing it.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
supersonic Posted June 2, 2015 Author Posted June 2, 2015 Your code is much better than my '$iCode = -12' because '$HDN_ENDTRACKW' seems to trigger only when resizing cols. Fantastic!
Moderators Melba23 Posted June 2, 2015 Moderators Posted June 2, 2015 supersonic, '$HDN_ENDTRACKW' seems to trigger only when resizing cols.Exactly. I am not sure what "-12" is, but I think it is a general mouse notification.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
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