?
Langsam verzweifel ich also hier mal ein bisschen Code vielleicht kann mir ja mal jemand sagen was ich falsch mache. Also ich will in jedes Elemens einer ListBox eine andere Linie zeichnen die ich mit CPen erzeugt habe.
Klappt aber irgedwie nicht er zeichnet es immer in alle Elemente.
Hier ist meine Drawitem:
void CEditListDlg::OnDrawItem(int id, LPDRAWITEMSTRUCT lpDrawItemStruct)
{
CDC dc;
dc.Attach(lpDrawItemStruct->hDC);
// Save these value to restore them when done drawing.
COLORREF crOldTextColor = RGB(0,0,0);
COLORREF crOldBkColor = RGB(255,255,255);
// If this item is selected, set the background color
// and the text color to appropriate values. Also, erase
// rect by filling it with the background color.
if ((lpDrawItemStruct->itemAction | ODA_SELECT) && (lpDrawItemStruct->itemState & ODS_SELECTED))
{
dc.SetTextColor(255);
dc.SetBkColor(0);
dc.FillSolidRect(&lpDrawItemStruct->rcItem,
0);
}
else
dc.FillSolidRect(&lpDrawItemStruct->rcItem, crOldBkColor);
// If this item has the focus, draw a red frame around the
// item's rect.
if ((lpDrawItemStruct->itemAction | ODA_FOCUS) && (lpDrawItemStruct->itemState & ODS_FOCUS))
{
CBrush br(RGB(0, 0, 0));
dc.FrameRect(&lpDrawItemStruct->rcItem, &br);
}
CPen pen (PS_DASH,1,RGB(255,0,0));
if (lpDrawItemStruct->itemID == 0 )
{
dc.SetBkMode(TRANSPARENT);
dc.SelectObject(pen);
dc.SetBkMode(TRANSPARENT);
dc.MoveTo(2,10);
dc.LineTo(180,10);
}
dc.Detach();
danke im voraus