⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ownlist.cpp

📁 一个用C++写的电力系统故障录波数据管理系统
💻 CPP
字号:
// OwnList.cpp : implementation file
// See OwnList.h for details on how to use this class
//

#include "stdafx.h"
#include "OwnList.h"
#include "wgl_32Doc.h"

#ifdef _DEBUG
#undef THIS_FILE
static char BASED_CODE THIS_FILE[] = __FILE__;
#endif

#define COLOR_ITEM_HEIGHT   20
/////////////////////////////////////////////////////////////////////////////
// COwnerDrawListBox

COwnerDrawListBox::COwnerDrawListBox(CWgl_32Doc * p)
{
	pCWgl_32Doc = p;
}

COwnerDrawListBox::~COwnerDrawListBox()
{
}


BEGIN_MESSAGE_MAP(COwnerDrawListBox, CListBox)
	//{{AFX_MSG_MAP(COwnerDrawListBox)
		// NOTE - the ClassWizard will add and remove mapping macros here.
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()


/////////////////////////////////////////////////////////////////////////////
// COwnerDrawListBox message handlers

void COwnerDrawListBox::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) 
{
	CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC);
	int cn = (int)lpDrawItemStruct->itemID;

	COLORREF color = pCWgl_32Doc->m_pChannelIndex[cn].Color;
	CRect rcItem(lpDrawItemStruct->rcItem);

	int y = rcItem.top+COLOR_ITEM_HEIGHT/2;
	CPen Pen(PS_SOLID,2,color);
	CPen *OldPen=(CPen *)pDC->SelectObject(&Pen);
	pDC->MoveTo(0,y);
	pDC->LineTo(rcItem.right,y);
	pDC->SelectObject(OldPen);
	y = rcItem.top;
	COLORREF OldClr,BKClr;
	BOOL bClr=lpDrawItemStruct->itemAction & ODA_FOCUS;
	bClr=bClr && lpDrawItemStruct->itemState & ODS_FOCUS;
	BOOL bBKC=lpDrawItemStruct->itemState & ODS_SELECTED;
	if(bBKC)
		BKClr =  pDC->SetTextColor(RGB(0,255,0));
	if(bClr)
		OldClr = pDC->SetTextColor(RGB(255,0,255));
	cn = (int)lpDrawItemStruct->itemData;
	CString strTemp;
	strTemp.Format("%-1d",cn+1);
	pDC->TextOut(0,y,strTemp);
	if(bClr) pDC->SetTextColor(OldClr);
	if(bBKC) pDC->SetTextColor(BKClr);
}

int COwnerDrawListBox::CompareItem(LPCOMPAREITEMSTRUCT lpCompareItemStruct) 
{
	int color1 = (int)lpCompareItemStruct->itemData1;
	int color2 = (int)lpCompareItemStruct->itemData2;
	if (color1 == color2)
		return 0;       // exact match
	else if(color1 < color2)
		return -1;
	else 
		return 1;
}

void COwnerDrawListBox::MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct)
{
	lpMeasureItemStruct->itemHeight = COLOR_ITEM_HEIGHT;
}

void COwnerDrawListBox::AddListItem(int item)
{
	AddString((LPCTSTR) item);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -