Click here to Skip to main content
15,895,875 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.
// MyCell - version 1.0
// Written by Yanxueming <yanxm2003@hotmail.com>
// Copyright (C) 2006-2006
// All rights reserved.
//
// The code and information is provided "as-is" without
// warranty of any kind, either expressed or implied.
#pragma once

#ifndef WM_MOUSEWHEEL
#define WM_MOUSEWHEEL                   0x020A
#endif

namespace mycell{
	class Grid;
	class ScrollImp
	{
		Grid* pGrid_;
	public:		  
		ScrollImp(Grid* p):pGrid_(p)
		{}
		BEGIN_MSG_MAP(ScrollImp)
			MESSAGE_HANDLER(WM_VSCROLL,OnVScroll)
			MESSAGE_HANDLER(WM_HSCROLL,OnHScroll)
			MESSAGE_HANDLER(WM_MOUSEWHEEL, OnMouseWheel)
		END_MSG_MAP()

	public:
		//void ResetScrollBars(BOOL bResetHCrollBar,BOOL bResetVScrollBar);
		//int GetScrollPos32(HWND hWnd,int nBar, BOOL bGetTrackPos  = FALSE )
		//{
		//	SCROLLINFO si;
		//	si.cbSize = sizeof(SCROLLINFO);
		//	if (bGetTrackPos){
		//		si.fMask = SIF_TRACKPOS;
		//		if (::GetScrollInfo(hWnd,nBar, &si))
		//			return si.nTrackPos;
		//	}else {
		//		si.fMask = SIF_POS;
		//		if (::GetScrollInfo(hWnd,nBar, &si))
		//			return si.nPos;
		//	}
		//	return 0;
		//}
		//BOOL SetScrollPos32(HWND hWnd,int nBar, int nPos, BOOL bRedraw  = TRUE )
		//{
		//	SCROLLINFO si;
		//	si.cbSize = sizeof(SCROLLINFO);
		//	si.fMask  = SIF_POS;
		//	si.nPos   = nPos;
		//	return ::SetScrollInfo(hWnd,nBar, &si, bRedraw);
		//}
	private:
		LRESULT OnVScroll(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
		LRESULT OnHScroll(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
		LRESULT OnMouseWheel(UINT,WPARAM,LPARAM,BOOL&);
	};
}//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