From: Vadim Zeitlin <vadim@wxwidgets.org>
Date: Wed, 10 Sep 2003 13:20:04 +0000 (+0000)
Subject: attempts to fix virtual list control with Unicode and MSLU
X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/fa17ced1b55a0dd89e7bead4905248d33e879bd4

attempts to fix virtual list control with Unicode and MSLU


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@23474 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
---

diff --git a/src/msw/listctrl.cpp b/src/msw/listctrl.cpp
index af488d4e41..3c9adee638 100644
--- a/src/msw/listctrl.cpp
+++ b/src/msw/listctrl.cpp
@@ -2145,6 +2145,10 @@ bool wxListCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result)
                 }
                 break;
 
+                // when using MSLU we get ANSI messages sometimes, apparently
+#if wxUSE_UNICODE_MSLU
+            case LVN_GETDISPINFOA:
+#endif // wxUSE_UNICODE_MSLU
             case LVN_GETDISPINFO:
                 if ( IsVirtual() )
                 {
@@ -2156,7 +2160,29 @@ bool wxListCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result)
                     if ( lvi.mask & LVIF_TEXT )
                     {
                         wxString text = OnGetItemText(item, lvi.iSubItem);
-                        wxStrncpy(lvi.pszText, text, lvi.cchTextMax);
+#if wxUSE_UNICODE_MSLU
+                        if ( nmhdr->code == LVN_GETDISPINFOA )
+                        {
+                            if ( !::WideCharToMultiByte
+                                    (
+                                        CP_ACP,
+                                        0,          // no flags
+                                        text,
+                                        text.length() + 1,
+                                        (char *)lvi.pszText,
+                                        lvi.cchTextMax,
+                                        NULL,       // default character
+                                        NULL        // [out] def char used flag
+                                    ) )
+                            {
+                                wxLogLastError(_T("WideCharToMultiByte()"));
+                            }
+                        }
+                        else 
+#endif // wxUSE_UNICODE_MSLU
+                        {
+                            wxStrncpy(lvi.pszText, text, lvi.cchTextMax);
+                        }
                     }
 
                     // see comment at the end of wxListCtrl::GetColumn()