Re: CListCtrl unicode doesn't display korean characters correctly
Thanks for your answer.
I'm sorry, I forgot to say that my system is windows XP sp2 pro french (IE7)
And the compiler is VC6 - latest service pack.
MrAsm a ?crit :
On Wed, 04 Apr 2007 10:12:07 +0200, Dansk <dansk@laouilest.com> wrote:
Any hint?
Maybe you should post some code to get more help...
It won't be obvious to show some code, the application is quite complex.
See below...
I think that the problem probability is 0.000001% Windows and
99.999999% yours :)
I think so too! and I really hope that I am not in the 0.000001%!
Maybe you passed a bad string to CList, or some other problem...
Maybe.
I forgot to mention that I tested it with Purify which did not reported
any problem.
MrAsm
Here is the code that gives the string to the ListCtrl
The korean string is in case 2.
The LoadString method gets it from the resources.
/////////////////////////////////////////////////////////////////////////////
void CMyDlg::OnGetdispinfoList(NMHDR* pNMHDR, LRESULT* pResult)
{
LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR;
LV_ITEM* pItem= &(pDispInfo)->item;
int iItemIndx = pItem->iItem;
ASSERT(iItemIndx>=0 && ItemIndx<_DisplayedStringElements.GetSize());
if (pItem->mask & LVIF_TEXT) //valid text buffer?
{
switch(pItem->iSubItem){
case 0: //fill in main text
lstrcpy(pItem->pszText,
_DisplayedStringElements[iItemIndx]->_NumberStr);
break;
case 1: //fill in sub item 1 text
lstrcpy(pItem->pszText,
_DisplayedStringElements[iItemIndx]->_ID);
break;
case 2: //fill in sub item 2 text
{
if(iItemIndx<=_DisplayedStringElements.GetSize() &&
_DisplayedStringElements[iItemIndx])
{
CString *Value =
&_DisplayedStringElements[iItemIndx]->_Value;
if (Value->IsEmpty())
{
if (!LoadString(*Value,
_DisplayedStringElements[iItemIndx]->_Number))
{
Value->Format(_T("<No string for value
%lu>"), _DisplayedStringElements[iItemIndx]->_Number);
}
}
try {
if(Value->GetLength()>256)
lstrcpy(pItem->pszText,
Value->Left(256)+_T("..."));
else
lstrcpy(pItem->pszText, *Value);
} catch(...) {
lstrcpy(pItem->pszText, _T("--> Unexpected
error <--"));
}
}
}
break;
}
}
*pResult = 0;
}
And this is how I initialize my ListCtrl named m_List
// ListCtrl Font
CFont *ListFont = m_List.GetFont();
if(ListFont)
{
LOGFONT LogFont;
ListFont->GetLogFont(&LogFont);
lstrcpy(LogFont.lfFaceName, _T("Arial Unicode MS"));
if(!_ListCtrlFont.CreateFontIndirect(&LogFont)) {
lstrcpy(LogFont.lfFaceName, _T("Arial"));
_ListCtrlFont.CreateFontIndirect(&LogFont);
}
m_List.SetFont(&_ListCtrlFont);
}
m_List.SetExtendedStyle(LVS_EX_FULLROWSELECT|LVS_EX_INFOTIP|LVS_EX_GRIDLINES);