From d90ef8e4c243a66548765fa1e502dbb55589d723 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 6 Mar 2009 10:54:56 +0000 Subject: [PATCH] only set maximal tooltip width if it's greater than the previously set one to avoid breaking long lines if a shorter tooltip is added afterwards (see #10537) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@59366 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/msw/tooltip.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/msw/tooltip.cpp b/src/msw/tooltip.cpp index 8277cdfb67..e92fb061e7 100644 --- a/src/msw/tooltip.cpp +++ b/src/msw/tooltip.cpp @@ -394,9 +394,16 @@ void wxToolTip::Add(WXHWND hWnd) if ( ms_maxWidth != -1 && maxWidth > ms_maxWidth ) maxWidth = ms_maxWidth; - // only set a new width if it is bigger than the current setting - SendTooltipMessage(GetToolTipCtrl(), TTM_SETMAXTIPWIDTH, - wxUIntToPtr(maxWidth)); + // only set a new width if it is bigger than the current setting: + // otherwise adding a tooltip with shorter line(s) than a previous + // one would result in breaking the longer lines unnecessarily as + // all our tooltips share the same maximal width + if ( maxWidth > SendTooltipMessage(GetToolTipCtrl(), + TTM_GETMAXTIPWIDTH, 0) ) + { + SendTooltipMessage(GetToolTipCtrl(), TTM_SETMAXTIPWIDTH, + wxUIntToPtr(maxWidth)); + } } else #endif // TTM_SETMAXTIPWIDTH -- 2.45.2