From 5e7b515349561e869205bb8afb028d587592accd Mon Sep 17 00:00:00 2001 From: oneeyeman1 Date: Fri, 23 Aug 2019 21:34:30 -0500 Subject: [PATCH] Avoid showing 2 tooltips simultaneously in wxMSW wxListCtrl Only show the built-in control tooltips if we're not showing any custom ones. Closes https://github.com/wxWidgets/wxWidgets/pull/1500 Closes #10492. --- include/wx/msw/listctrl.h | 3 +++ src/msw/listctrl.cpp | 20 +++++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/include/wx/msw/listctrl.h b/include/wx/msw/listctrl.h index 8a3908ffbe..da1cb79063 100644 --- a/include/wx/msw/listctrl.h +++ b/include/wx/msw/listctrl.h @@ -390,6 +390,9 @@ protected: { return MSWGetBestViewRect(width, -1).y; } virtual int DoGetBestClientWidth(int height) const wxOVERRIDE { return MSWGetBestViewRect(-1, height).x; } +#if wxUSE_TOOLTIPS + virtual void DoSetToolTip(wxToolTip *tip) wxOVERRIDE; +#endif // wxUSE_TOOLTIPS wxSize MSWGetBestViewRect(int x, int y) const; diff --git a/src/msw/listctrl.cpp b/src/msw/listctrl.cpp index 386a7d1a4e..653c375369 100644 --- a/src/msw/listctrl.cpp +++ b/src/msw/listctrl.cpp @@ -327,7 +327,6 @@ void wxListCtrl::MSWSetExListStyles() // we want to have some non default extended // styles because it's prettier (and also because wxGTK does it like this) int exStyle = - LVS_EX_LABELTIP | LVS_EX_FULLROWSELECT | LVS_EX_SUBITEMIMAGES | // normally this should be governed by a style as it's probably not @@ -335,6 +334,13 @@ void wxListCtrl::MSWSetExListStyles() // it seems better to enable it by default than disable LVS_EX_HEADERDRAGDROP; + // Showing the tooltip items not fitting into the control is nice, but not + // really compatible with having custom tooltips, as this could result in + // showing 2 tooltips simultaneously, which would be confusing. So only + // enable this style if there is no risk of this happening. + if ( !GetToolTip() ) + exStyle |= LVS_EX_LABELTIP; + if ( wxApp::GetComCtl32Version() >= 600 ) { // We must enable double buffering when using the system theme to avoid @@ -3605,4 +3611,16 @@ static void wxConvertToMSWListCol(HWND hwndList, } } +#if wxUSE_TOOLTIPS + +void wxListCtrl::DoSetToolTip(wxToolTip *tip) +{ + wxWindow::DoSetToolTip(tip); + + // Add or remove LVS_EX_LABELTIP style as necessary. + MSWSetExListStyles(); +} + +#endif // wxUSE_TOOLTIPS + #endif // wxUSE_LISTCTRL