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

📄 rxgrid1.cpp

📁 此源码为汽车数据采集分析系统
💻 CPP
字号:
// RxGrid1.cpp : implementation file
//

#include "stdafx.h"
#include "cartest.h"
#include "RxGrid1.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// RxGrid

RxGrid::RxGrid()
{
}

RxGrid::~RxGrid()
{
}


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

/////////////////////////////////////////////////////////////////////////////
// RxGrid message handlers

void RxGrid::PreSubclassWindow() 
{
this->ModifyStyle(LVS_EDITLABELS,0L);
	this->ModifyStyle(0L,LVS_REPORT);
	this->ModifyStyle(0L,LVS_SHOWSELALWAYS);
	this->SetExtendedStyle(LVS_EX_FULLROWSELECT|LVS_EX_HEADERDRAGDROP|LVS_EX_GRIDLINES|LVS_EX_ONECLICKACTIVATE|LVS_EX_FLATSB);
	this->InsertColumn(0,"轴名",LVCFMT_LEFT,75,0);
	
	this->InsertColumn(2,"轴重",LVCFMT_CENTER,90,0);
	this->InsertColumn(3,"左制动力",LVCFMT_CENTER,130,0);
	this->InsertColumn(3,"右制动力",LVCFMT_CENTER,130,0);
	this->InsertColumn(4,"左动态制动力",LVCFMT_CENTER,130,0);
	this->InsertColumn(5,"右动态制动力",LVCFMT_CENTER,130,0);
	this->InsertColumn(6,"制动率(%)",LVCFMT_CENTER,120,0);
	this->InsertColumn(7,"不平衡率(%)",LVCFMT_CENTER,120,0);
	this->InsertColumn(8,"左阻滞率(%)",LVCFMT_CENTER,120,0);
	this->InsertColumn(9,"右阻滞率(%)",LVCFMT_CENTER,120,0);

    this->InsertItem(0,"前  轴");
	this->InsertItem (1,"后  轴");
    this->InsertItem (2,"手制动");
	this->InsertItem(3,"总制动");	
	CListCtrl::PreSubclassWindow();
}
bool RxGrid::SetRecortdset(_RecordsetPtr rst)
{
	_variant_t bName,bValue;
	//添加列
	for(int nCol=0;nCol<rst->GetFields()->GetCount();nCol++)
	{
		bName=rst->GetFields()->GetItem((long)nCol)->Name;
		this->InsertColumn(nCol,(_bstr_t)bName);
	}
	int nCurRow=0;
	//添加行
	try{
		rst->MoveFirst();
	}
	catch(...)
	{
		goto AutoWidth;    //没有记录
	}
	while(!rst->adoEOF)
	{
		this->InsertItem(nCurRow,0);
		for(nCol=0;nCol<rst->GetFields()->GetCount();nCol++)
		{
			try{
				bValue=rst->GetFields()->GetItem((long)nCol)->Value;
			}
			catch(...)
			{
				break;
			}
			if(bValue.vt!=VT_NULL&& bValue.vt!=VT_EMPTY)
				this->SetItemText(nCurRow,nCol,(_bstr_t)bValue);
		}
		rst->MoveNext();
		nCurRow++;
	}
AutoWidth:
	for(nCol=0;nCol<rst->GetFields()->GetCount();nCol++)
	{
		this->SetColumnWidth(nCol,LVSCW_AUTOSIZE_USEHEADER );
	}
	return true;
}	

⌨️ 快捷键说明

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