Items are not visible in a ListBox [modified]
-
In ListBox i'm using it to display the Strings, After adding it to resource it's property is set as ownerdraw fixed and Single selection When i create an object of it, as CCheckListBox the items are being displayed, but when i create an object of CListbox/CNewListBox(Which is derived from CListBox) the items are not visible. I overriden the DrawItem in CNewListBox, i suspect there must be some problem with the overriden function. But the irony is when i use the same class in a small application it is working perfect, but in my main application the listbox items are not at all visible. void CNewListBox::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) { CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC); if (lpDrawItemStruct->itemID == (UINT)-1) { // Draws item text int h = lpDrawItemStruct->rcItem.bottom - lpDrawItemStruct->rcItem.top; pDC->SetBkMode(TRANSPARENT); lpDrawItemStruct->rcItem.left += h; int i= pDC->DrawText((LPCTSTR)lpDrawItemStruct->itemData, &lpDrawItemStruct->rcItem, DT_LEFT); } } What's the wrong/ or missing? Would Appreciate any help
modified on Sunday, January 25, 2009 11:40 PM
-
In ListBox i'm using it to display the Strings, After adding it to resource it's property is set as ownerdraw fixed and Single selection When i create an object of it, as CCheckListBox the items are being displayed, but when i create an object of CListbox/CNewListBox(Which is derived from CListBox) the items are not visible. I overriden the DrawItem in CNewListBox, i suspect there must be some problem with the overriden function. But the irony is when i use the same class in a small application it is working perfect, but in my main application the listbox items are not at all visible. void CNewListBox::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) { CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC); if (lpDrawItemStruct->itemID == (UINT)-1) { // Draws item text int h = lpDrawItemStruct->rcItem.bottom - lpDrawItemStruct->rcItem.top; pDC->SetBkMode(TRANSPARENT); lpDrawItemStruct->rcItem.left += h; int i= pDC->DrawText((LPCTSTR)lpDrawItemStruct->itemData, &lpDrawItemStruct->rcItem, DT_LEFT); } } What's the wrong/ or missing? Would Appreciate any help
modified on Sunday, January 25, 2009 11:40 PM
Do you specify LBS_HASSTRINGS (checkbox in resource editor)?
Best wishes, Hans
[CodeProject Forum Guidelines] [How To Ask A Question] [My Articles]
-
Do you specify LBS_HASSTRINGS (checkbox in resource editor)?
Best wishes, Hans
[CodeProject Forum Guidelines] [How To Ask A Question] [My Articles]