Click here to Skip to main content
14,040,625 members
Click here to Skip to main content
Add your own
alternative version


28 bookmarked
Posted 12 Mar 2001


, 12 Mar 2001
Rate this:
Please Sign up or sign in to vote.
A Static derived class which provides a check box to enable/disable items inside it
  • Download source files - 17 Kb
  • Download demo project - 7 Kb
  • Sample Image - CCheckStatic.gif


    Recently at work, I was asked for help trying to put a button on top of a static box, and decided instead to write a class that encapsulated the behaviour desired. I promptly did nothing about it, until last night my crying son left me no chances of sleep and the idea came back to me in my semi-exausted stupor.

    Basically the idea is this: if you drag out a static box to bound some controls, you can go into the header file and change the variable type to CCheckStatic, and automatically you will have a check box in the top left corner of the static, and checking/unchecking the box will enable/disable any control inside the box that has a TAB stop ( well, almost, read the screen of the demo for some known issues ). When I say automatically, don't forget you need to call the Init() method in your OnInitDialog in order to set it all up.

    If you want to get a bit more fancy, you can simply add ID's of items you want to control, and only those items will be effected. This allows you to both exclude items within the box and also include items outside it. It also means you don't need a TAB stop on each item in the box. So it's probably the best way to go, but it requires some more setting up and I always like the idea of a class being able to take care of itself, as well as being flexible, so both behaviours are presented for your gourmet selection...

    Here is a list of the methods exposed by CCheckStatic. It's hopefully pretty self explanatory.

    //void Init();  // Though shalt always call this before using my class.
    //int AddItem(int ID);       // Adds a control to the custom list
    //void ClearItems();         // Empties the custom list
    //void SetCheck(BOOL check); // Sets the check state and toggles dialog items

    That's about all I have to say. Feel free to send suggestions/flames/FatBrain gift vouchers to the above address as you see fit.


    This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

    A list of licenses authors might use can be found here


    About the Author

    Christian Graus
    Software Developer (Senior)
    Australia Australia
    Programming computers ( self taught ) since about 1984 when I bought my first Apple ][. Was working on a GUI library to interface Win32 to Python, and writing graphics filters in my spare time, and then building n-tiered apps using asp, atl and in my job at Dytech. After 4 years there, I've started working from home, at first for Code Project and now for a vet telemedicine company. I owned part of a company that sells client education software in the vet market, but we sold that and I worked for the owners for five years before leaving to get away from the travel, and spend more time with my family. I now work for a company here in Hobart, doing all sorts of Microsoft based stuff in C++ and C#, with a lot of T-SQL in the mix.

    You may also be interested in...

    Comments and Discussions

    GeneralMy vote of 5 Pin
    Sharjith9-Nov-10 11:26
    professionalSharjith9-Nov-10 11:26 
    GeneralMy vote of 1 Pin
    jasssii23-Feb-10 0:20
    memberjasssii23-Feb-10 0:20 
    GeneralMy vote of 1 Pin
    jesjsi23-Feb-10 0:19
    memberjesjsi23-Feb-10 0:19 
    GeneralMy vote of 1 Pin
    jessssi23-Feb-10 0:19
    memberjessssi23-Feb-10 0:19 
    GeneralMy vote of 1 Pin
    jessssii23-Feb-10 0:18
    memberjessssii23-Feb-10 0:18 
    GeneralMy vote of 1 Pin
    jessiiiii23-Feb-10 0:18
    memberjessiiiii23-Feb-10 0:18 
    GeneralMy vote of 1 Pin
    jess3123-Feb-10 0:17
    memberjess3123-Feb-10 0:17 
    GeneralMy vote of 1 Pin
    jess223-Feb-10 0:17
    memberjess223-Feb-10 0:17 
    GeneralMy vote of 1 Pin
    jessi123-Feb-10 0:16
    memberjessi123-Feb-10 0:16 
    GeneralMy vote of 1 Pin
    jessca23-Feb-10 0:12
    memberjessca23-Feb-10 0:12 
    GeneralMy vote of 1 Pin
    arvinder_aneja29-Jan-10 23:47
    memberarvinder_aneja29-Jan-10 23:47 
    QuestionOn Vc++ Pin
    vijay_aroli9-Feb-07 3:17
    membervijay_aroli9-Feb-07 3:17 
    Generalget rid of the Init() required to be called for initialization Pin
    zikTronics26-Dec-06 3:31
    memberzikTronics26-Dec-06 3:31 
    Questionwho will send notification? Pin
    Anonymous17-Feb-03 15:10
    memberAnonymous17-Feb-03 15:10 
    AnswerRe: who will send notification? Pin
    drewpy11-Jun-03 19:12
    memberdrewpy11-Jun-03 19:12 
    GeneralTab stop for the check box Pin
    Gavin Greig10-Jun-02 4:02
    memberGavin Greig10-Jun-02 4:02 
    GeneralGreat Tool....Added Enable/Disable Pin
    Tony Fontenot4-Jul-01 18:23
    memberTony Fontenot4-Jul-01 18:23 
    GeneralI have been.... a stupid man. Pin
    Christian Graus21-Mar-01 14:45
    protectorChristian Graus21-Mar-01 14:45 
    GeneralDisable, depending on the rectangle Pin
    19-Mar-01 9:25
    suss19-Mar-01 9:25 
    GeneralRe: Disable, depending on the rectangle Pin
    Christian Graus19-Mar-01 23:16
    protectorChristian Graus19-Mar-01 23:16 
    GeneralRe: Disable, depending on the rectangle Pin
    Christian Graus19-Mar-01 23:28
    protectorChristian Graus19-Mar-01 23:28 
    GeneralNice, but... Pin
    Jim Koornneef14-Mar-01 4:02
    memberJim Koornneef14-Mar-01 4:02 
    GeneralRe: Nice, but... Pin
    Christian Graus14-Mar-01 11:13
    protectorChristian Graus14-Mar-01 11:13 

    General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    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 | Cookies | Terms of Use | Mobile
    Web05 | 2.8.190425.1 | Last Updated 13 Mar 2001
    Article Copyright 2001 by Christian Graus
    Everything else Copyright © CodeProject, 1999-2019
    Layout: fixed | fluid