Click here to Skip to main content
15,895,667 members
Articles / Desktop Programming / WTL

A fast and lightweight cell control

Rate me:
Please Sign up or sign in to vote.
4.42/5 (31 votes)
11 Mar 2008CPOL1 min read 91K   4.5K   81  
A fast and lightweight cell control for displaying tabular data. The cell is a custom control derived from ATL::CWindow.
#include "stdafx.h"
#include "../include/SelectionBound.h"
#include "../include/ASelection.h"
#include "../include/GridBase.h"
namespace mycell{
	SelectionBound::SelectionBound(GridBase* pGrid):pGrid_(pGrid)
	{}
	//void SelectionBound::DrawErease(HDC hDC)
	//{
	//	//SetROP2(hDC,R2_XORPEN);
	//	DrawBound(hDC,rcBound_);
	//}
	//void SelectionBound::DrawBound(HDC hDC,LPCRECT)
	//{
	//	CDCHandle dc(hDC);
	//	//SetROP2(hDC,R2_XORPEN);
	//	HBRUSH hOldBrush=dc.SelectBrush((HBRUSH)GetStockObject(NULL_BRUSH));
	//	CPen pen;
	//	pen.CreatePen(PS_SOLID,3,RGB(0,0,0));
	//	HPEN hOldPen=dc.SelectPen(pen);
	//	dc.Rectangle(&rc);
	//	dc.SelectPen(hOldPen);
	//	dc.SelectBrush(hOldBrush);
	//}
	void SelectionBound::Draw(HDC hDC,LPCRECT lprc)
	{
		return;
		//ASelection* pSel=pGrid_->pSelection_;
		/*
		CellRange cr=pSel->GetActiveSelection();
		cr.Normalize();
		RECT rc=pGrid_->get_RangeRect(&cr);
		if(rc.top>=lprc->bottom || rc.bottom<=lprc->top
			||rc.left>=lprc->right || rc.right<=lprc->left)
			return;

		CDCHandle dc(hDC);
		CPen pen;
		{
			LOGBRUSH lb;
			lb.lbColor=RGB(0,0,0);
			lb.lbStyle=BS_SOLID;
			lb.lbHatch=0;
			pen.Attach(ExtCreatePen(PS_GEOMETRIC|PS_SOLID|PS_ENDCAP_SQUARE,3,&lb,0,NULL));
		}		
		HPEN hOldPen=dc.SelectPen(pen);

		RECT rcCell=pGrid_->GetCellRect(cr.first.row-1,cr.first.col);
		RECT rcCell1=pGrid_->GetCellRect(cr.first.row-1,cr.second.col);

		dc.MoveTo(max(lprc->left,rcCell.left+1),min(lprc->bottom,rcCell.bottom-2));
		dc.LineTo(min(lprc->right,rcCell1.right-2),min(lprc->bottom,rcCell.bottom-2));

		rcCell=pGrid_->GetCellRect(cr.second.row,cr.second.col);
		dc.MoveTo(min(lprc->right,rcCell1.right),max(lprc->top,rcCell1.bottom-2));
		dc.LineTo(min(lprc->right,rcCell1.right),min(lprc->bottom,rcCell.bottom-2));


		dc.SelectPen(hOldPen);
		*/
		/*
		const static int nInf=5;
		if(rc.top<=lprc->top)
			rc.top=max(0,lprc->top-nInf);
		if(rc.bottom>=lprc->bottom)
			rc.bottom=lprc->bottom+nInf;
		if(rc.left<=lprc->left)
			rc.left=max(0,lprc->left-nInf);
		if(rc.right>=lprc->right)
			rc.right=lprc->right+nInf;

		rcBound_=rc;
		DrawBound(hDC,&rc);
		*/
	}
}//namespace mycell

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer
China China
My name is Yanxueming,i live in Chengdu China.Graduated from UESTC in 1999.

Comments and Discussions