Here is a patch which preserves alot of your structure. it works to correct my bug in Outlook.
-aric
Dimitrie O. Paun wrote:
On November 21, 2002 10:19 am, Aric Stewart wrote:
I wondered if you had found a counter example in your own tests, or if you had just assumed that windows would act rationally. If it was an assumption then I will happily make a patch that mimic the behavior of my test program. If you have your own windows test program that shows other behavior maybe you can send it to me and we can see what is wrong with my test program.
Actually, I don't have a test for the WM_NOTIFYFORMAT. In fact, I was just looking at it, trying to compare it to the Treeview case which doesn't work at the moment, and I think the one in Listview is buggy, at least according to the documentation. To cut a long story short: yeah, a patch is greatly appreciated! :)
BTW, this is the problem with the Treeview as well, if I understand correctly. It is asked in WM_NOTIFYFORMAT to be Unicode, but when it does, nothing works. So my question is: when is a control supposed to be Unicode? WTF is going on here???
Index: dlls/comctl32/listview.c =================================================================== RCS file: /home/wine/wine/dlls/comctl32/listview.c,v retrieving revision 1.330 diff -u -r1.330 listview.c --- dlls/comctl32/listview.c 18 Nov 2002 19:51:11 -0000 1.330 +++ dlls/comctl32/listview.c 21 Nov 2002 16:30:44 -0000 @@ -764,8 +764,10 @@ }
/* - Send notification. depends on dispinfoW having same - structure as dispinfoA. + With testing on Windows 2000 it looks like the notify format + has nothing to do with this message. It ALWAYS seems to be + in ansi format. + infoPtr : listview struct notificationCode : *Unicode* notification code pdi : dispinfo structure (can be unicode or ansi) @@ -774,61 +776,49 @@ static BOOL notify_dispinfoT(LISTVIEW_INFO *infoPtr, INT notificationCode, LPNMLVDISPINFOW pdi, BOOL isW) { BOOL bResult = FALSE; - BOOL convertToAnsi = FALSE, convertToUnicode = FALSE; - INT realNotifCode; + BOOL convertToAnsi = FALSE; INT cchTempBufMax = 0, savCchTextMax = 0; LPWSTR pszTempBuf = NULL, savPszText = NULL;
if ((pdi->item.mask & LVIF_TEXT) && is_textT(pdi->item.pszText, isW)) - { - convertToAnsi = (isW && infoPtr->notifyFormat == NFR_ANSI); - convertToUnicode = (!isW && infoPtr->notifyFormat == NFR_UNICODE); - } + convertToAnsi = isW;
- if (convertToAnsi || convertToUnicode) + if (convertToAnsi) { - if (notificationCode != LVN_GETDISPINFOW) - { - cchTempBufMax = convertToUnicode ? - MultiByteToWideChar(CP_ACP, 0, (LPCSTR)pdi->item.pszText, -1, NULL, 0): - WideCharToMultiByte(CP_ACP, 0, pdi->item.pszText, -1, NULL, 0, NULL, NULL); + if (notificationCode != LVN_GETDISPINFOW) + { + cchTempBufMax = 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, - (convertToUnicode ? sizeof(WCHAR) : sizeof(CHAR)) * cchTempBufMax); + pszTempBuf = HeapAlloc(GetProcessHeap(), 0, sizeof(CHAR) * + cchTempBufMax); if (!pszTempBuf) return FALSE; - if (convertToUnicode) - 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); + + WideCharToMultiByte(CP_ACP, 0, pdi->item.pszText, -1, (LPSTR) + pszTempBuf, cchTempBufMax, NULL, NULL); + savCchTextMax = pdi->item.cchTextMax; savPszText = pdi->item.pszText; pdi->item.pszText = pszTempBuf; pdi->item.cchTextMax = cchTempBufMax; }
- if (infoPtr->notifyFormat == 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, (LPNMHDR)pdi); + TRACE(" pdi->item=%s\n", debuglvitem_t(&pdi->item, infoPtr->notifyFormat != + NFR_ANSI)); + + bResult = notify_hdr(infoPtr, get_ansi_notification(notificationCode), + (LPNMHDR)pdi);
- if (convertToUnicode || convertToAnsi) + 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, - savPszText, savCchTextMax); + MultiByteToWideChar(CP_ACP, 0, (LPSTR) pdi->item.pszText, -1, + savPszText, savCchTextMax); pdi->item.pszText = savPszText; /* restores our buffer */ pdi->item.cchTextMax = savCchTextMax; HeapFree(GetProcessHeap(), 0, pszTempBuf);