Click here to Skip to main content
11,927,378 members (51,578 online)
Click here to Skip to main content
Add your own
alternative version


28 bookmarked


, 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 Links -->
  • Download source files - 17 Kb
  • Download demo project - 7 Kb
  • <!-- Article image -->

    Sample Image - CCheckStatic.gif

    <!-- Main HTML starts here -->


    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 12:26
    memberSharjith9-Nov-10 12:26 
    GeneralMy vote of 1 Pin
    jasssii23-Feb-10 1:20
    memberjasssii23-Feb-10 1:20 
    GeneralMy vote of 1 Pin
    jesjsi23-Feb-10 1:19
    memberjesjsi23-Feb-10 1:19 
    GeneralMy vote of 1 Pin
    jessssi23-Feb-10 1:19
    memberjessssi23-Feb-10 1:19 
    GeneralMy vote of 1 Pin
    jessssii23-Feb-10 1:18
    memberjessssii23-Feb-10 1:18 
    GeneralMy vote of 1 Pin
    jessiiiii23-Feb-10 1:18
    memberjessiiiii23-Feb-10 1:18 
    GeneralMy vote of 1 Pin
    jess3123-Feb-10 1:17
    memberjess3123-Feb-10 1:17 
    GeneralMy vote of 1 Pin
    jess223-Feb-10 1:17
    memberjess223-Feb-10 1:17 
    GeneralMy vote of 1 Pin
    jessi123-Feb-10 1:16
    memberjessi123-Feb-10 1:16 
    GeneralMy vote of 1 Pin
    jessca23-Feb-10 1:12
    memberjessca23-Feb-10 1:12 
    GeneralMy vote of 1 Pin
    arvinder_aneja30-Jan-10 0:47
    memberarvinder_aneja30-Jan-10 0:47 
    QuestionOn Vc++ Pin
    vijay71739-Feb-07 4:17
    membervijay71739-Feb-07 4:17 
    Generalget rid of the Init() required to be called for initialization Pin
    zikTronics26-Dec-06 4:31
    memberzikTronics26-Dec-06 4:31 
    Questionwho will send notification? Pin
    Anonymous17-Feb-03 16:10
    sussAnonymous17-Feb-03 16:10 
    AnswerRe: who will send notification? Pin
    drewpy11-Jun-03 20:12
    memberdrewpy11-Jun-03 20:12 
    GeneralTab stop for the check box Pin
    Gavin Greig10-Jun-02 5:02
    memberGavin Greig10-Jun-02 5:02 
    GeneralGreat Tool....Added Enable/Disable Pin
    Tony Fontenot4-Jul-01 19:23
    memberTony Fontenot4-Jul-01 19:23 
    GeneralI have been.... a stupid man. Pin
    Christian Graus21-Mar-01 15:45
    memberChristian Graus21-Mar-01 15:45 
    GeneralDisable, depending on the rectangle Pin
    Anonymous19-Mar-01 10:25
    memberAnonymous19-Mar-01 10:25 
    GeneralRe: Disable, depending on the rectangle Pin
    Christian Graus20-Mar-01 0:16
    memberChristian Graus20-Mar-01 0:16 
    GeneralRe: Disable, depending on the rectangle Pin
    Christian Graus20-Mar-01 0:28
    memberChristian Graus20-Mar-01 0:28 
    GeneralNice, but... Pin
    Jim Koornneef14-Mar-01 5:02
    memberJim Koornneef14-Mar-01 5:02 
    GeneralRe: Nice, but... Pin
    Christian Graus14-Mar-01 12:13
    memberChristian Graus14-Mar-01 12: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.

    | Advertise | Privacy | Terms of Use | Mobile
    Web02 | 2.8.151126.1 | Last Updated 13 Mar 2001
    Article Copyright 2001 by Christian Graus
    Everything else Copyright © CodeProject, 1999-2015
    Layout: fixed | fluid