comctl32: tooltips: Remove broken support for non-NULL-terminated strings in TOOLTIPS_GetDispInfo[AW].
This commit is contained in:
parent
31be5005c6
commit
f53e314180
|
@ -148,6 +148,7 @@ VOID COMCTL32_RefreshSysColors(void);
|
||||||
void COMCTL32_DrawInsertMark(HDC hDC, const RECT *lpRect, COLORREF clrInsertMark, BOOL bHorizontal);
|
void COMCTL32_DrawInsertMark(HDC hDC, const RECT *lpRect, COLORREF clrInsertMark, BOOL bHorizontal);
|
||||||
void COMCTL32_EnsureBitmapSize(HBITMAP *pBitmap, int cxMinWidth, int cyMinHeight, COLORREF crBackground);
|
void COMCTL32_EnsureBitmapSize(HBITMAP *pBitmap, int cxMinWidth, int cyMinHeight, COLORREF crBackground);
|
||||||
INT Str_GetPtrWtoA (LPCWSTR lpSrc, LPSTR lpDest, INT nMaxLen);
|
INT Str_GetPtrWtoA (LPCWSTR lpSrc, LPSTR lpDest, INT nMaxLen);
|
||||||
|
INT Str_GetPtrAtoW (LPCSTR lpSrc, LPWSTR lpDest, INT nMaxLen);
|
||||||
BOOL Str_SetPtrAtoW (LPWSTR *lppDest, LPCSTR lpSrc);
|
BOOL Str_SetPtrAtoW (LPWSTR *lppDest, LPCSTR lpSrc);
|
||||||
BOOL Str_SetPtrWtoA (LPSTR *lppDest, LPCWSTR lpSrc);
|
BOOL Str_SetPtrWtoA (LPSTR *lppDest, LPCWSTR lpSrc);
|
||||||
|
|
||||||
|
|
|
@ -922,6 +922,47 @@ INT Str_GetPtrWtoA (LPCWSTR lpSrc, LPSTR lpDest, INT nMaxLen)
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**************************************************************************
|
||||||
|
* Str_GetPtrAtoW [internal]
|
||||||
|
*
|
||||||
|
* Converts a multibyte string into a unicode string
|
||||||
|
*
|
||||||
|
* PARAMS
|
||||||
|
* lpSrc [I] Pointer to the multibyte source string
|
||||||
|
* lpDest [O] Pointer to caller supplied storage for the unicode string
|
||||||
|
* nMaxLen [I] Size, in characters, of the destination buffer
|
||||||
|
*
|
||||||
|
* RETURNS
|
||||||
|
* Length, in characters, of the converted string.
|
||||||
|
*/
|
||||||
|
|
||||||
|
INT Str_GetPtrAtoW (LPCSTR lpSrc, LPWSTR lpDest, INT nMaxLen)
|
||||||
|
{
|
||||||
|
INT len;
|
||||||
|
|
||||||
|
TRACE("(%s %p %d)\n", debugstr_a(lpSrc), lpDest, nMaxLen);
|
||||||
|
|
||||||
|
if (!lpDest && lpSrc)
|
||||||
|
return MultiByteToWideChar(CP_ACP, 0, lpSrc, -1, 0, 0);
|
||||||
|
|
||||||
|
if (nMaxLen == 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (lpSrc == NULL) {
|
||||||
|
lpDest[0] = '\0';
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
len = MultiByteToWideChar(CP_ACP, 0, lpSrc, -1, 0, 0);
|
||||||
|
if (len >= nMaxLen)
|
||||||
|
len = nMaxLen - 1;
|
||||||
|
|
||||||
|
MultiByteToWideChar(CP_ACP, 0, lpSrc, -1, lpDest, len);
|
||||||
|
lpDest[len] = '\0';
|
||||||
|
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
* Str_SetPtrAtoW [internal]
|
* Str_SetPtrAtoW [internal]
|
||||||
|
|
|
@ -336,17 +336,11 @@ static void TOOLTIPS_GetDispInfoA(HWND hwnd, TOOLTIPS_INFO *infoPtr, TTTOOL_INFO
|
||||||
infoPtr->szTipText[0] = '\0';
|
infoPtr->szTipText[0] = '\0';
|
||||||
}
|
}
|
||||||
else if (ttnmdi.lpszText != LPSTR_TEXTCALLBACKA) {
|
else if (ttnmdi.lpszText != LPSTR_TEXTCALLBACKA) {
|
||||||
INT max_len = (ttnmdi.lpszText == &ttnmdi.szText[0]) ?
|
Str_GetPtrAtoW(ttnmdi.lpszText, infoPtr->szTipText, INFOTIPSIZE);
|
||||||
sizeof(ttnmdi.szText)/sizeof(ttnmdi.szText[0]) : -1;
|
|
||||||
MultiByteToWideChar(CP_ACP, 0, ttnmdi.lpszText, max_len,
|
|
||||||
infoPtr->szTipText, INFOTIPSIZE);
|
|
||||||
if (ttnmdi.uFlags & TTF_DI_SETITEM) {
|
if (ttnmdi.uFlags & TTF_DI_SETITEM) {
|
||||||
INT len = MultiByteToWideChar(CP_ACP, 0, ttnmdi.lpszText,
|
|
||||||
max_len, NULL, 0);
|
|
||||||
toolPtr->hinst = 0;
|
toolPtr->hinst = 0;
|
||||||
toolPtr->lpszText = Alloc (len * sizeof(WCHAR));
|
toolPtr->lpszText = NULL;
|
||||||
MultiByteToWideChar(CP_ACP, 0, ttnmdi.lpszText, -1,
|
Str_SetPtrW(&toolPtr->lpszText, infoPtr->szTipText);
|
||||||
toolPtr->lpszText, len);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -385,14 +379,11 @@ static void TOOLTIPS_GetDispInfoW(HWND hwnd, TOOLTIPS_INFO *infoPtr, TTTOOL_INFO
|
||||||
infoPtr->szTipText[0] = '\0';
|
infoPtr->szTipText[0] = '\0';
|
||||||
}
|
}
|
||||||
else if (ttnmdi.lpszText != LPSTR_TEXTCALLBACKW) {
|
else if (ttnmdi.lpszText != LPSTR_TEXTCALLBACKW) {
|
||||||
INT max_len = (ttnmdi.lpszText == &ttnmdi.szText[0]) ?
|
Str_GetPtrW(ttnmdi.lpszText, infoPtr->szTipText, INFOTIPSIZE);
|
||||||
sizeof(ttnmdi.szText)/sizeof(ttnmdi.szText[0]) : INFOTIPSIZE-1;
|
|
||||||
lstrcpynW(infoPtr->szTipText, ttnmdi.lpszText, max_len);
|
|
||||||
if (ttnmdi.uFlags & TTF_DI_SETITEM) {
|
if (ttnmdi.uFlags & TTF_DI_SETITEM) {
|
||||||
INT len = max(strlenW(ttnmdi.lpszText), max_len);
|
|
||||||
toolPtr->hinst = 0;
|
toolPtr->hinst = 0;
|
||||||
toolPtr->lpszText = Alloc ((len+1) * sizeof(WCHAR));
|
toolPtr->lpszText = NULL;
|
||||||
memcpy(toolPtr->lpszText, ttnmdi.lpszText, (len+1) * sizeof(WCHAR));
|
Str_SetPtrW(&toolPtr->lpszText, infoPtr->szTipText);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
Loading…
Reference in New Issue