Fixed: Don't use CListBox itemData for drawing text, it doesn't actually point to the item string
This commit is contained in:
parent
6cc30e7e6b
commit
f688c23580
1 changed files with 4 additions and 4 deletions
|
@ -118,13 +118,12 @@ const string &CToolsZoneList::getItem (uint32 nIndex)
|
|||
void CToolsZoneList::DrawItem (LPDRAWITEMSTRUCT lpDrawItemStruct)
|
||||
{
|
||||
ASSERT(lpDrawItemStruct->CtlType == ODT_LISTBOX);
|
||||
LPCTSTR lpszText = (LPCTSTR) lpDrawItemStruct->itemData;
|
||||
if (lpszText == NULL)
|
||||
return;
|
||||
CDC dc;
|
||||
|
||||
if (lpDrawItemStruct->itemID >= _BitmapList.size())
|
||||
return;
|
||||
if (lpDrawItemStruct->itemID >= _ItemNames.size())
|
||||
return;
|
||||
|
||||
dc.Attach (lpDrawItemStruct->hDC);
|
||||
|
||||
|
@ -168,7 +167,8 @@ void CToolsZoneList::DrawItem (LPDRAWITEMSTRUCT lpDrawItemStruct)
|
|||
}
|
||||
|
||||
// Draw the text.
|
||||
dc.DrawText (lpszText, _tcslen(lpszText), &rectLeft, DT_CENTER|DT_SINGLELINE|DT_VCENTER);
|
||||
NLMISC::tstring itemName = NLMISC::utf8ToTStr(_ItemNames[lpDrawItemStruct->itemID]);
|
||||
dc.DrawText(itemName.c_str(), itemName.size(), &rectLeft, DT_CENTER|DT_SINGLELINE|DT_VCENTER);
|
||||
|
||||
// Reset the background color and the text color back to their original values.
|
||||
dc.SetTextColor (crOldTextColor);
|
||||
|
|
Loading…
Reference in a new issue