M
Nachtrag:
ich hab jetzt mal von hand - immer wenn sich was an der CListCtrl tut - ein SendMessage(DrawItem eingefügt)...
theListCtrl->SendMessage(WM_DRAWITEM, 0, 0);
In OnDrawItem hab ich einfach mal den Code aus dem ListBox-Beispiel reingetan, um zu gucken, was passiert...der sieht so aus:
Das Programm steigt schon beim Holen des CDCs aus. Offensichtlich muß ich wohl beim Senden der Message noch die Parameter befüllen...aber wie??..wo soll ich dann beim Senden z.b. den CDC herbesorgen....kann mir da mal jemand auf die Sprünge helfen...(..warum muß MFC auch alles nur so überkomplizieren...ich will doch einfach bloß n Listeneintrag größer zeichnen....)
//CRect members to store the position of the items
CRect rItem;
CRect rText;
CRect rIcon;
CDC* dc = CDC::FromHandle(lpDrawItemStruct->hDC);
if ((int)lpDrawItemStruct->itemID < 0)
{
// If there are no elements in the List Box
// based on whether the list box has Focus or not
// draw the Focus Rect or Erase it,
if ((lpDrawItemStruct->itemAction & ODA_FOCUS) &&
(lpDrawItemStruct->itemState & ODS_FOCUS))
{
dc->DrawFocusRect(&lpDrawItemStruct->rcItem);
}
else if ((lpDrawItemStruct->itemAction & ODA_FOCUS) &&
!(lpDrawItemStruct->itemState & ODS_FOCUS))
{
dc->DrawFocusRect(&lpDrawItemStruct->rcItem);
}
return;
}
// String to store the text
CString strText;
// Get the item text.
GetText(lpDrawItemStruct->itemID, strText);
//Initialize the Item's row
rItem = lpDrawItemStruct->rcItem;
rIcon = lpDrawItemStruct->rcItem;
rIcon.bottom = rIcon.top + 16;
rIcon.right = rIcon.left + 16;
//Start drawing the text 2 pixels after the icon
rText.left = rIcon.right + 2;
rText.top = rIcon.top;
UINT nFormat = DT_LEFT | DT_SINGLELINE | DT_VCENTER;
if (GetStyle() & LBS_USETABSTOPS)
nFormat |= DT_EXPANDTABS;
// If item selected, draw the highlight rectangle.
// Or if item deselected, draw the rectangle using the window color.
if ((lpDrawItemStruct->itemState & ODS_SELECTED) &&
(lpDrawItemStruct->itemAction & (ODA_SELECT | ODA_DRAWENTIRE)))
{
CBrush br(::GetSysColor(COLOR_HIGHLIGHT));
dc->FillRect(&rItem, &br);
}
else if (!(lpDrawItemStruct->itemState & ODS_SELECTED) &&
(lpDrawItemStruct->itemAction & ODA_SELECT))
{
CBrush br(::GetSysColor(COLOR_WINDOW));
dc->FillRect(&rItem, &br);
}
// If the item has focus, draw the focus rect.
// If the item does not have focus, erase the focus rect.
if ((lpDrawItemStruct->itemAction & ODA_FOCUS) &&
(lpDrawItemStruct->itemState & ODS_FOCUS))
{
dc->DrawFocusRect(&rItem);
}
else if ((lpDrawItemStruct->itemAction & ODA_FOCUS) &&
!(lpDrawItemStruct->itemState & ODS_FOCUS))
{
dc->DrawFocusRect(&rItem);
}
// To draw the Text set the background mode to Transparent.
int iBkMode = dc->SetBkMode(TRANSPARENT);
COLORREF crText;
if (lpDrawItemStruct->itemState & ODS_SELECTED)
crText = dc->SetTextColor(::GetSysColor(COLOR_HIGHLIGHTTEXT));
else if (lpDrawItemStruct->itemState & ODS_DISABLED)
crText = dc->SetTextColor(::GetSysColor(COLOR_GRAYTEXT));
else
crText = dc->SetTextColor(::GetSysColor(COLOR_WINDOWTEXT));
CPoint pt(rIcon.left,rIcon.top);
g_Image_List.Draw(dc,0,pt,ILD_NORMAL);
dc->TextOut(rText.left,rText.top,strText);
//Draw the Text
dc->SetTextColor(crText);