1. Define message mapping functions
H File: AFX_MSG Void OncustomDraw (NmHDR * PNMHDR, LRESULT * PRESULT); CPP file: on_notify_reflect (nm_customdraw, oncustomDraw)
void CMyListCtrl :: OnCustomdraw (NMHDR * pNMHDR, LRESULT * pResult) {NMLVCUSTOMDRAW * pLVCD = reinterpret_cast
. Prep the DC for the text drawing Note // that the entire item RECT is filled in, so this emulates the full- // row selection style of normal lists pDC-> FillSolidRect (rcItem, crBkgnd);. PDC-> SetBkMode ( TRANSPARENT); if (pimage! = Null) {// Get The Rect this Holds The item's icon. GetItemRect (NITEM, & RCITEM, LVIR_ICON); // Draw the icon. Uformat = Ild_Transparent; Pimage-> DRAW (PDC, RITEM. IIMAGE, RCITEM.TOPLEFT (), UFORMAT);} // Draw The Background & Prep The DC for the text Drawing. Note // That The Entire Item Rect IS Filled in, So this Emulates The full full- // Row Selection Style of normal lists.GetItemRect (nItem, rcItem, LVIR_LABEL); pDC-> FillSolidRect (rcItem, crBkgnd); pDC-> SetBkMode (TRANSPARENT);. // Tweak the rect a bit for nicer-looking text alignment rcText1 = rcText = rcItem; // rctext.Left = 3; rctext.top = 3; rcText.bottom - = rcText.height () * 2/5; rctext1.top = rcText.bottom;
// Draw the text. CallLogptr Pitem = (CallLogptr) GetItemData (NITEM);
IF (pitem! = null) {if (_TCSLEN (wchar *) pitem-> strname)! = 0) {Stext = (wchar *) Pitem-> strname; if (_TCSCMP (wchar *) Pitem-> Strcontact, (Wchar *) pitem-> strname)! = 0) {Stext = _t (") cString ((wchar *) pitem-> strcontact) _t (") ");}} else stext = (Wchar *) pitem-> strcontact; // pdc-> drawtext (stext, rctext, dt_vcenter | dt_singeline);
CFont vertFont, tipFont; CFont * pOldFont; // Font vertFont.CreateFont (15, 0, 0, 0, FW_NORMAL, 0, 0, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, _T ( "MS Sans Serif") ); tipFont.CreateFont (10, 0, 0, 0, FW_NORMAL, 0, 0, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, _T ( "MS Sans Serif")); pOldFont = pDC-> SelectObject (& vertFont ); PDC-> DRAWTEXT (Stext, rctext, dt_vcenter | dt_singeline); ctime m_time (pitem-> dwbegintime); cstract txtbelow = _t ("); txtBElow.format (_t ("% D-% 02D-% 02D% 02D:% 02D "), m_time.getyear (), m_time.getday (), m_time.getday (), m_time.getMinute (); if (Pitem-> dwlasting! = 0) {CSTRING CALLTIME; INT DAY, HOUR, Minute, Second, Tmp; Day = Pitem-> dwlasting / (24 * 60 * 60); TMP = Pitem-> dwlasting% (24 * 60 * 60); Hour = TMP / (60 * 60); TMP = Tmp% (60 * 60); minute = TMP / 60; second = Tmp% 60; I f (day! = 0) CallTime.Format (_T ("% D,% D:% 02D:% 02D"), DAY, HOUR, Minute, Second); Else IF (Hour! = 0) CallTime.Format (_t) ("% D:% 02D:% 02D"), Hour, minute, second; else CallTime.Format (_T ("% 02d:% 02d"), Minute, Second); csyslogdlg * pParent = null; pparent = Csyslogdlg *) this-> getParent ();