LVN_GETDISPINFO seems to always be Ansi.

This commit is contained in:
Aric Stewart 2002-11-25 01:11:11 +00:00 committed by Alexandre Julliard
parent 473d6cbd27
commit eb56d81956
1 changed files with 30 additions and 40 deletions

View File

@ -764,8 +764,10 @@ static int get_ansi_notification(INT unicodeNotificationCode)
} }
/* /*
Send notification. depends on dispinfoW having same With testing on Windows 2000 it looks like the notify format
structure as dispinfoA. has nothing to do with this message. It ALWAYS seems to be
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)
@ -774,24 +776,19 @@ 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, convertToUnicode = FALSE; BOOL convertToAnsi = FALSE;
INT realNotifCode;
INT cchTempBufMax = 0, savCchTextMax = 0; INT cchTempBufMax = 0, savCchTextMax = 0;
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 || convertToUnicode) if (convertToAnsi)
{ {
if (notificationCode != LVN_GETDISPINFOW) if (notificationCode != LVN_GETDISPINFOW)
{ {
cchTempBufMax = convertToUnicode ? cchTempBufMax = WideCharToMultiByte(CP_ACP, 0, pdi->item.pszText,
MultiByteToWideChar(CP_ACP, 0, (LPCSTR)pdi->item.pszText, -1, NULL, 0): -1, NULL, 0, NULL, NULL);
WideCharToMultiByte(CP_ACP, 0, pdi->item.pszText, -1, NULL, 0, NULL, NULL);
} }
else else
{ {
@ -799,34 +796,27 @@ static BOOL notify_dispinfoT(LISTVIEW_INFO *infoPtr, INT notificationCode, LPNML
*pdi->item.pszText = 0; /* make sure we don't process garbage */ *pdi->item.pszText = 0; /* make sure we don't process garbage */
} }
pszTempBuf = HeapAlloc(GetProcessHeap(), 0, pszTempBuf = HeapAlloc(GetProcessHeap(), 0, sizeof(CHAR) *
(convertToUnicode ? sizeof(WCHAR) : sizeof(CHAR)) * cchTempBufMax); cchTempBufMax);
if (!pszTempBuf) return FALSE; if (!pszTempBuf) return FALSE;
if (convertToUnicode)
MultiByteToWideChar(CP_ACP, 0, (LPCSTR)pdi->item.pszText, -1, WideCharToMultiByte(CP_ACP, 0, pdi->item.pszText, -1, (LPSTR)
pszTempBuf, cchTempBufMax); pszTempBuf, cchTempBufMax, NULL, NULL);
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;
pdi->item.pszText = pszTempBuf; pdi->item.pszText = pszTempBuf;
pdi->item.cchTextMax = cchTempBufMax; pdi->item.cchTextMax = cchTempBufMax;
} }
if (infoPtr->notifyFormat == NFR_ANSI) TRACE(" pdi->item=%s\n", debuglvitem_t(&pdi->item, infoPtr->notifyFormat !=
realNotifCode = get_ansi_notification(notificationCode); NFR_ANSI));
else
realNotifCode = notificationCode;
TRACE(" pdi->item=%s\n", debuglvitem_t(&pdi->item, infoPtr->notifyFormat != NFR_ANSI));
bResult = notify_hdr(infoPtr, realNotifCode, (LPNMHDR)pdi);
if (convertToUnicode || convertToAnsi) bResult = notify_hdr(infoPtr, get_ansi_notification(notificationCode),
(LPNMHDR)pdi);
if (convertToAnsi)
{ {
if (convertToUnicode) /* note : pointer can be changed by app ! */
WideCharToMultiByte(CP_ACP, 0, pdi->item.pszText, -1, (LPSTR) savPszText,
savCchTextMax, NULL, NULL);
else
MultiByteToWideChar(CP_ACP, 0, (LPSTR) pdi->item.pszText, -1, MultiByteToWideChar(CP_ACP, 0, (LPSTR) pdi->item.pszText, -1,
savPszText, savCchTextMax); savPszText, savCchTextMax);
pdi->item.pszText = savPszText; /* restores our buffer */ pdi->item.pszText = savPszText; /* restores our buffer */