Click here to Skip to main content
Click here to Skip to main content
Go to top

Blinking Cells For Chris Maunder's Grid Control

, 13 May 2005
Rate this:
Please Sign up or sign in to vote.
Create blinking cells for Chris Maunder's grid control.

Introduction

I had cause to make use of Chris Maunder's outstanding grid control in a recent project, but it was missing some very necessary functionality - the ability to blink one or more cells. This article discusses how I added this capability. It boils down to a derived class that does the work, and a thread that provides the ticker to turn on/off a "blinking cell" (I don't really believe in WM_TIMER). I used the code from these two additional CP articles:

General

Since the grid control supports cell colors, all I had to do was come up with a way to make a cell look like it was blinking, and then come with a way to actually make it blink. To make it look like it was blinking, I came up with a class that contains the original colors of the specified cell, as well as the blink colors for the specified cell. How you determine these colors is completely up to you, and most likely it's going to be application-specific. For our application, we wanted the cell to blink with a red background and white text.

The CBlinkCell Class

This class is extremely simple having nothing more than variables that contain the cell's row, column, and original background and foreground colors.

The CBlinkCellList Class

This class is equally simplistic in its construction, and it merely contains a list of cells that are supposed to be blinking. If a CBlinkCell item is in this list, the CBlinkGridCtrl class will blink the cell (specified by the row/column data members) until it's removed from the list. This class allows you to add and remove/delete cells from the blink list.

The CBlinkGridCtrl Class

This class is derived from the original CGridCtrl class, and simply adds the new blinking functionality. This way, you can insert this class at the appropriate spot in your inheritance chain without losing any functionality that you added to the grid control (or your own derived classes).

Using the CBlinkGridCtrl Class

Simply derive your own grid control from CBlinkGridCtrl. After that, it's a simple matter of starting the blink thread (which you can do from within your derived grid control), and then writing code to turn blinking for the desired cell(s) on and off.

Notes

I put the resource ID for the grid control used in the sample app into the file Constants.h. This is also where the user defined message for the blink tick is found.

Credit Where Credit Is Due

Many thanks go out to Chris Maunder for writing the original CGridCtrl code. We're currently using that code in an application that tracks patients as they are serviced in a trauma center.

The thread class I'm using was originally written by Dominik Filipp. It's an old article (from 1999) here on CP, but it does the job quite nicely. I also make use of his thread class in many of my own applications.

Links to both of these articles are provided at the beginning of the article.

License

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

Share

About the Author

John Simmons / outlaw programmer
Software Developer (Senior)
United States United States
I've been paid as a programmer since 1982 with experience in Pascal, and C++ (both self-taught), and began writing Windows programs in 1991 using Visual C++ and MFC. In the 2nd half of 2007, I started writing C# Windows Forms and ASP.Net applications, and have since done WPF, Silverlight, WCF, web services, and Windows services.
 
My weakest point is that my moments of clarity are too brief to hold a meaningful conversation that requires more than 30 seconds to complete. Thankfully, grunts of agreement are all that is required to conduct most discussions without committing to any particular belief system.

Comments and Discussions

 
GeneralSlider in a Cell PinmemberTier525-Feb-06 10:42 
GeneralRe: Slider in a Cell PinmemberJohn Simmons / outlaw programmer26-Feb-06 1:16 
Generalbroken link Pinmemberr.guerzoni16-May-05 1:55 
GeneralRe: broken link PinmemberJohn Simmons / outlaw programmer16-May-05 5:37 
Generaldislike of WM_TIMER Pinmember.dan.g.15-May-05 14:02 
GeneralRe: dislike of WM_TIMER PinmemberJohn Simmons / outlaw programmer16-May-05 5:06 
General"Legal Disclaimer" offensive Pinmembercsmac314413-May-05 10:17 
Generaland by posting this you hope to....? Pinmember
MadHatter ¢
13-May-05 12:33 
GeneralIrrelevant PinmemberDaTxomin15-May-05 5:29 
GeneralRe: Irrelevant PinmemberJohn Simmons / outlaw programmer16-May-05 5:29 
GeneralRe: Irrelevant PinmemberDaTxomin16-May-05 6:44 
GeneralRe: "Legal Disclaimer" offensive PinmemberBill S15-May-05 2:07 
GeneralRe: "Legal Disclaimer" offensive Pinmember.dan.g.15-May-05 14:01 
GeneralRe: "Legal Disclaimer" offensive PinmemberJohn Simmons / outlaw programmer16-May-05 5:30 
GeneralRe: "Legal Disclaimer" offensive PinmemberShog915-May-05 17:16 
First off, i can see how you might be offended. I don't care, but i can see.
 
Second, you need to learn what racism is, and more to the point, what it isn't. Calling something racist just because you don't like it does a disservice to those who have fought to overcome true racism in society. There are plenty of generic cuss words if you just need a word to emphasize your displeasure.
 
Finally, wtf? I scrolled all the way down here to read discussions relevant to blinking grid cells. This is totally irrelevant - there are facilities to email the author, and even a message board on Simmons' profile if you have some beef with his bio text that you simply must tell someone about.
 
You must be careful in the forest
Broken glass and rusty nails
If you're to bring back something for us
I have bullets for sale...

GeneralRe: "Legal Disclaimer" offensive PinmemberJohn Simmons / outlaw programmer16-May-05 5:32 
GeneralRe: "Legal Disclaimer" offensive PinmemberJohn Simmons / outlaw programmer16-May-05 5: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.

| Advertise | Privacy | Mobile
Web01 | 2.8.140916.1 | Last Updated 13 May 2005
Article Copyright 2005 by John Simmons / outlaw programmer
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid