Click here to Skip to main content
Licence CPOL
First Posted 29 Jun 2006
Views 44,996
Downloads 2,366
Bookmarked 61 times

A fast and lightweight cell control

By | 11 Mar 2008 | Article
A fast and lightweight cell control for displaying tabular data. The cell is a custom control derived from ATL::CWindow.

Sample Image - MyCell.PNG

Introduction

A fast and lightweight cell control which can be easily extended was my requirement. There are some grid controls derived or subclassed with CListCtrl already available. CListCtrl is great and very fast, but still has some limitations, such as it has no row header, and merging cells is not easy to support. Last month, I decided to write my own grid control, and wanted to share my source code with others here, because some of my knowledge is learned from CodeProject. Thanks to Chris Maunder for his MFC Grid control 2.25; I learned a lot from it. And, thanks Vladislav Gelfer for his RgnLight class which is very useful for clipping.

Requirements

  • ATL 7.0/7.1
  • WTL 7.5/8.0

Emphasis

Use the APIs GetRegionData and ScrollWindow to reduce repainting is the main idea for speeding up the painting of the grid. Only those cells with invalid states need to be re-drawn, so there is no need to re-draw the valid cells. When we do it this way, there is no flicker, even if do not use memdc, and the painting is very fast.

Infrastructure

Features

  1. Like Excel, a Workbook manages many Worksheets.
  2. Merge and unmerge cells.
  3. Freeze.
  4. Import/export XML (Excel format).
  5. Styles (font, border, alignment, fill, ...).
  6. Default/custom cell symbol.
  7. Default/custom cell editor.
  8. Using light weight COM object makes easily extendible.
  9. Use real/virtual mode to manage data.
  10. Drag active selection.
  11. Single selection or multi-selection support.

History

  • 17 July, 2006 - Supports editing cells.
  • 17 July, 2006 - Supports merging cells.
  • 11 July, 2006 - Auto scroll in selection model when mouse is out of the grid client area.

Conclusion

Any comments or questions can be sent to xueming.yan@gmail.com.

License

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

About the Author

xueming.yan

Web Developer

China China

Member

My name is Yanxueming,i live in Chengdu China.Graduated from UESTC in 1999.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
QuestionVC++2010:fatal error C1083: Cannot open include file: 'atlapp.h': No such file or directory PinmemberPaul Soloveychik7:39 31 Mar '11  
AnswerRe: VC++2010:fatal error C1083: Cannot open include file: 'atlapp.h': No such file or directory PinmemberRichard GILL1:43 3 Apr '12  
GeneralThank´s PinmemberJoao Araujo11:37 30 Nov '09  
QuestionIt doesn't allow entering some text into CELL? Pinmembermichael. zhao16:47 12 Mar '08  
AnswerRe: It doesn't allow entering some text into CELL? Pinmemberxueming.yan19:40 12 Mar '08  
Generalusing c++ MFC vc6 Pinmemberori kovacsi18:46 11 Jul '06  
GeneralRe: using c++ MFC vc6 Pinmemberxueming.yan21:32 11 Jul '06  
GeneralNice: some suggestions PinmemberJerry Evans1:40 1 Jul '06  
GeneralRe: Nice: some suggestions Pinmemberxueming.yan15:57 2 Jul '06  
GeneralRe: Nice: some suggestions Pinmemberxueming.yan15:37 3 Jul '06  
GeneralErm... PinmemberDarka22:55 29 Jun '06  
GeneralRe: Erm... Pinmemberxueming.yan23:59 29 Jun '06  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web01 | 2.5.120517.1 | Last Updated 12 Mar 2008
Article Copyright 2006 by xueming.yan
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid