We help IT Professionals succeed at work.

Unicode and List View common control

myson asked
Medium Priority
Last Modified: 2008-02-26
I've got a Win32API nonMFC C++ program, which is compiled with UNICODE directive. Program is run under Win2000. I have in that application a dialog box with a List View control. When I ask IsWindowUnicode(), it replies with TRUE. I add an item to it with some non-ascii and non-local codepage characters in widechar string. I ask for the text and i compare it char by char and it is the same. But list view displays instead of those chars an thick vertical line. When I create a file named exactly like that string, Windows Explorer displays those chars OK. How can I make my list view to properly display non-ascii and non-local codepage characters?

Thanks in advance,
Watch Question

AxterSenior Software Engineer

Can you show the code you're using to add the text to the listview?


listitem.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM;
listitem.iItem = iIndex;
listitem.iSubItem = 0;
listitem.pszText = LPSTR_TEXTCALLBACK;
listitem.iImage = 0;
listitem.lParam  = (LPARAM) pItemData;
if(ListView_InsertItem(hwndList, &listitem) == -1)
    return FALSE;

Callback notification:

case LVN_GETDISPINFO:                    
     LV_DISPINFO pnmv = (LV_DISPINFO *) lParam;
     if (pnmv->item.mask & LVIF_TEXT)
       ITEMDATA * pItem = (ITEMDATA *) pnmv->item.lParam;
       switch (pnmv->item.iSubItem)
        case 0:
     lstrcpyn(pnmv->item.pszText, pItem->szItemName, pnmv->item.cchTextMax);


I hope pretty standard. But I don't think the problem is in this.
>>non-ascii and non-local codepage

I suspect that non-local codepage means "not the current system locale".

In short, if you have say English or German as the current system language, you cannot display say Chinese or Russian in GUI elements like menu or listview. You can display English and the current language only (and other languages that have the same codepage as the current language).

But you can display literally any language in a Rich Edit control.


Hmm, yeah. This is what I have wanted. Thanks.

Explore More ContentExplore courses, solutions, and other research materials related to this topic.