Extended maximum tooltip length (in non-Unicode comctl32 4.70+ mode) from (MSW limited) 39 chars to 512 chars (customizable).
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@25828 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -3222,32 +3222,26 @@ bool wxWindowMSW::HandleTooltipNotify(WXUINT code,
|
|||||||
// in Unicode mode this is just what we need
|
// in Unicode mode this is just what we need
|
||||||
ttText->lpszText = (wxChar *)ttip.c_str();
|
ttText->lpszText = (wxChar *)ttip.c_str();
|
||||||
#else // !Unicode
|
#else // !Unicode
|
||||||
/*
|
// Convert tooltip from multi byte to Unicode.
|
||||||
MultiByteToWideChar(CP_ACP, 0, ttip, ttip.length()+1,
|
|
||||||
(wchar_t *)ttText->szText,
|
|
||||||
sizeof(ttText->szText) / sizeof(wchar_t));
|
|
||||||
*/
|
|
||||||
// Fix by dimitrishortcut: see patch 771772
|
|
||||||
|
|
||||||
// FIXME: szText has a max of 80 bytes, so limit the tooltip string
|
// We don't want to use the szText buffer because it has a limit of 80
|
||||||
// length accordingly. Ideally lpszText should be used, but who
|
// bytes, for now use our own static buffer with a higher fixed max
|
||||||
// would be responsible for freeing the buffer?
|
// length.
|
||||||
|
// Preferably a dynamic buffer should be used, but who frees the buffer?
|
||||||
|
|
||||||
// Maximum length of a tip is 39 characters. 39 is 80/2 minus 1 byte
|
static const int MAX_LENGTH = 512;
|
||||||
// needed for NULL character.
|
static wchar_t buf[MAX_LENGTH+1];
|
||||||
size_t tipLength = wxMin(ttip.Len(), 39);
|
|
||||||
|
ttText->lpszText = (LPSTR) buf;
|
||||||
|
|
||||||
|
// Truncate tooltip length if needed
|
||||||
|
size_t tipLength = wxMin(ttip.Len(), MAX_LENGTH);
|
||||||
|
|
||||||
// Convert to WideChar without adding the NULL character. The NULL
|
// Convert to WideChar without adding the NULL character. The NULL
|
||||||
// character is added afterwards (Could have used ttip.Left(tipLength)
|
// character is added afterwards (this is more efficient).
|
||||||
// and a cchMultiByte parameter of tipLength+1, but this is more
|
::MultiByteToWideChar(CP_ACP, 0, ttip, tipLength, buf, MAX_LENGTH);
|
||||||
//efficient.
|
|
||||||
::MultiByteToWideChar(CP_ACP, 0, ttip, tipLength,
|
|
||||||
(wchar_t *)ttText->szText,
|
|
||||||
sizeof(ttText->szText) / sizeof(wchar_t));
|
|
||||||
|
|
||||||
// Add the NULL character.
|
buf[tipLength] = '\0';
|
||||||
ttText->szText[tipLength*2+0] = '\0';
|
|
||||||
ttText->szText[tipLength*2+1] = '\0';
|
|
||||||
|
|
||||||
#endif // Unicode/!Unicode
|
#endif // Unicode/!Unicode
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user