Click here to Skip to main content
11,583,859 members (61,087 online)
Click here to Skip to main content

A fast and lightweight cell control

, 11 Mar 2008 CPOL 58.1K 3.9K 80
Rate this:
Please Sign up or sign in to vote.
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)

Share

About the Author

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

You may also be interested in...

Comments and Discussions

 
Generalgood article Pin
qusuo4-Mar-14 20:37
memberqusuo4-Mar-14 20:37 
General很好的控件,必须要顶! Pin
firespout27-Sep-13 2:42
memberfirespout27-Sep-13 2:42 
QuestionVC++2010:fatal error C1083: Cannot open include file: 'atlapp.h': No such file or directory Pin
Paul Soloveychik31-Mar-11 7:39
memberPaul Soloveychik31-Mar-11 7:39 
AnswerRe: VC++2010:fatal error C1083: Cannot open include file: 'atlapp.h': No such file or directory Pin
Richard GILL3-Apr-12 1:43
memberRichard GILL3-Apr-12 1:43 
GeneralThank´s Pin
Joao Araujo30-Nov-09 11:37
memberJoao Araujo30-Nov-09 11:37 
QuestionIt doesn't allow entering some text into CELL? Pin
michael. zhao12-Mar-08 16:47
membermichael. zhao12-Mar-08 16:47 
I can copy and paste some text into one cell but entering directly doesn't work...
AnswerRe: It doesn't allow entering some text into CELL? Pin
xueming.yan12-Mar-08 19:40
memberxueming.yan12-Mar-08 19:40 
Generalusing c++ MFC vc6 Pin
ori kovacsi11-Jul-06 18:46
memberori kovacsi11-Jul-06 18:46 
GeneralRe: using c++ MFC vc6 Pin
xueming.yan11-Jul-06 21:32
memberxueming.yan11-Jul-06 21:32 
GeneralNice: some suggestions Pin
Jerry Evans1-Jul-06 1:40
memberJerry Evans1-Jul-06 1:40 
GeneralRe: Nice: some suggestions Pin
xueming.yan2-Jul-06 15:57
memberxueming.yan2-Jul-06 15:57 
GeneralRe: Nice: some suggestions Pin
xueming.yan3-Jul-06 15:37
memberxueming.yan3-Jul-06 15:37 
GeneralErm... Pin
Darka29-Jun-06 22:55
memberDarka29-Jun-06 22:55 
GeneralRe: Erm... Pin
xueming.yan29-Jun-06 23:59
memberxueming.yan29-Jun-06 23:59 

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.

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