Send notification messages in the format dictated by

infoPtr->notifyFormat.
This commit is contained in:
Dimitrie O. Paun 2004-11-01 21:07:11 +00:00 committed by Alexandre Julliard
parent 1d945eaacc
commit f07f08cfe6

View File

@ -818,10 +818,8 @@ static int get_ansi_notification(INT unicodeNotificationCode)
} }
/* /*
With testing on Windows 2000 it looks like the notify format Send notification. depends on dispinfoW having same
has nothing to do with this message. It ALWAYS seems to be structure as dispinfoA.
in ansi format.
infoPtr : listview struct infoPtr : listview struct
notificationCode : *Unicode* notification code notificationCode : *Unicode* notification code
pdi : dispinfo structure (can be unicode or ansi) pdi : dispinfo structure (can be unicode or ansi)
@ -830,32 +828,40 @@ static int get_ansi_notification(INT unicodeNotificationCode)
static BOOL notify_dispinfoT(LISTVIEW_INFO *infoPtr, INT notificationCode, LPNMLVDISPINFOW pdi, BOOL isW) static BOOL notify_dispinfoT(LISTVIEW_INFO *infoPtr, INT notificationCode, LPNMLVDISPINFOW pdi, BOOL isW)
{ {
BOOL bResult = FALSE; BOOL bResult = FALSE;
BOOL convertToAnsi = FALSE; BOOL convertToAnsi = FALSE, convertToUnicode = FALSE;
INT cchTempBufMax = 0, savCchTextMax = 0; INT cchTempBufMax = 0, savCchTextMax = 0, realNotifCode;
LPWSTR pszTempBuf = NULL, savPszText = NULL; LPWSTR pszTempBuf = NULL, savPszText = NULL;
if ((pdi->item.mask & LVIF_TEXT) && is_textT(pdi->item.pszText, isW)) if ((pdi->item.mask & LVIF_TEXT) && is_textT(pdi->item.pszText, isW))
convertToAnsi = isW; {
convertToAnsi = (isW && infoPtr->notifyFormat == NFR_ANSI);
convertToUnicode = (!isW && infoPtr->notifyFormat == NFR_UNICODE);
}
if (convertToAnsi) if (convertToAnsi || convertToUnicode)
{ {
if (notificationCode != LVN_GETDISPINFOW) if (notificationCode != LVN_GETDISPINFOW)
{ {
cchTempBufMax = WideCharToMultiByte(CP_ACP, 0, pdi->item.pszText, cchTempBufMax = convertToUnicode ?
-1, NULL, 0, NULL, NULL); MultiByteToWideChar(CP_ACP, 0, (LPCSTR)pdi->item.pszText, -1, NULL, 0):
} WideCharToMultiByte(CP_ACP, 0, pdi->item.pszText, -1, NULL, 0, NULL, NULL);
else
{
cchTempBufMax = pdi->item.cchTextMax;
*pdi->item.pszText = 0; /* make sure we don't process garbage */
} }
else
{
cchTempBufMax = pdi->item.cchTextMax;
*pdi->item.pszText = 0; /* make sure we don't process garbage */
}
pszTempBuf = HeapAlloc(GetProcessHeap(), 0, sizeof(CHAR) * pszTempBuf = HeapAlloc(GetProcessHeap(), 0,
cchTempBufMax); (convertToUnicode ? sizeof(WCHAR) : sizeof(CHAR)) * cchTempBufMax);
if (!pszTempBuf) return FALSE; if (!pszTempBuf) return FALSE;
WideCharToMultiByte(CP_ACP, 0, pdi->item.pszText, -1, (LPSTR) if (convertToUnicode)
pszTempBuf, cchTempBufMax, NULL, NULL); MultiByteToWideChar(CP_ACP, 0, (LPCSTR)pdi->item.pszText, -1,
pszTempBuf, cchTempBufMax);
else
WideCharToMultiByte(CP_ACP, 0, pdi->item.pszText, -1, (LPSTR) pszTempBuf,
cchTempBufMax, NULL, NULL);
savCchTextMax = pdi->item.cchTextMax; savCchTextMax = pdi->item.cchTextMax;
savPszText = pdi->item.pszText; savPszText = pdi->item.pszText;
@ -863,16 +869,21 @@ static BOOL notify_dispinfoT(LISTVIEW_INFO *infoPtr, INT notificationCode, LPNML
pdi->item.cchTextMax = cchTempBufMax; pdi->item.cchTextMax = cchTempBufMax;
} }
TRACE(" pdi->item=%s\n", debuglvitem_t(&pdi->item, infoPtr->notifyFormat != if (infoPtr->notifyFormat == NFR_ANSI)
NFR_ANSI)); realNotifCode = get_ansi_notification(notificationCode);
else
realNotifCode = notificationCode;
TRACE(" pdi->item=%s\n", debuglvitem_t(&pdi->item, infoPtr->notifyFormat != NFR_ANSI));
bResult = notify_hdr(infoPtr, realNotifCode, &pdi->hdr);
bResult = notify_hdr(infoPtr, get_ansi_notification(notificationCode), if (convertToUnicode || convertToAnsi)
(LPNMHDR)pdi);
if (convertToAnsi)
{ {
MultiByteToWideChar(CP_ACP, 0, (LPSTR) pdi->item.pszText, -1, if (convertToUnicode) /* note : pointer can be changed by app ! */
savPszText, savCchTextMax); WideCharToMultiByte(CP_ACP, 0, pdi->item.pszText, -1, (LPSTR) savPszText,
savCchTextMax, NULL, NULL);
else
MultiByteToWideChar(CP_ACP, 0, (LPSTR) pdi->item.pszText, -1,
savPszText, savCchTextMax);
pdi->item.pszText = savPszText; /* restores our buffer */ pdi->item.pszText = savPszText; /* restores our buffer */
pdi->item.cchTextMax = savCchTextMax; pdi->item.cchTextMax = savCchTextMax;
HeapFree(GetProcessHeap(), 0, pszTempBuf); HeapFree(GetProcessHeap(), 0, pszTempBuf);