【VC开源代码栏目提醒】:网学会员为广大网友收集整理了,WZDLBOX.CPP,希望对大家有所帮助!
// WzdLBox.cpp : implementation file
//
#include "stdafx.h"
#include "wzd.h"
#include "WzdLBox.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CWzdListBox
CWzdListBox::CWzdListBox()
{
}
CWzdListBox::~CWzdListBox()
{
}
BEGIN_MESSAGE_MAP(CWzdListBox, CListBox)
//{{AFX_MSG_MAP(CWzdListBox)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CWzdListBox message handlers
void CWzdListBox::DrawItem(LPDRAWITEMSTRUCT lpDIS)
{
// get our device context and rectangle to draw to
CDC dc;
dc.Attach(lpDIS->hDC);
CRect rect(lpDIS->rcItem);
// if our item is selected, then set colors accordingly
// and fill in background
COLORREF bk= dc.GetBkColor();
COLORREF fg= dc.GetTextColor();
if (lpDIS->itemState & ODS_SELECTED)
{
bk=::GetSysColor(COLOR_HIGHLIGHT);
fg=::GetSysColor(COLOR_HIGHLIGHTTEXT);
}
dc.SetTextColor(fg);
CBrush brush(bk);
dc.FillRect(&rect, &brush);
// draw text
if (lpDIS->itemState & ODS_SELECTED)
rect.left+=10;
int nBkMode = dc.SetBkMode(TRANSPARENT);
CString str;
GetText(lpDIS->itemID,str);
dc.DrawText(str, &rect, DT_LEFT|DT_VCENTER);
// cleanup
dc.SetTextColor(fg);
dc.SetBkMode(nBkMode);
dc.Detach();
}