Click here to Skip to main content
Click here to Skip to main content

CCheckStatic

, 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 -->

    Introduction

    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.

    License

    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

    Share

    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 asp.net 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.

    Comments and Discussions

     
    GeneralMy vote of 5 PinmemberSharjith9-Nov-10 11:26 
    GeneralMy vote of 1 Pinmemberjasssii23-Feb-10 0:20 
    GeneralMy vote of 1 Pinmemberjesjsi23-Feb-10 0:19 
    GeneralMy vote of 1 Pinmemberjessssi23-Feb-10 0:19 
    GeneralMy vote of 1 Pinmemberjessssii23-Feb-10 0:18 
    GeneralMy vote of 1 Pinmemberjessiiiii23-Feb-10 0:18 
    GeneralMy vote of 1 Pinmemberjess3123-Feb-10 0:17 
    GeneralMy vote of 1 Pinmemberjess223-Feb-10 0:17 
    GeneralMy vote of 1 Pinmemberjessi123-Feb-10 0:16 
    GeneralMy vote of 1 Pinmemberjessca23-Feb-10 0:12 
    GeneralMy vote of 1 Pinmemberarvinder_aneja29-Jan-10 23:47 
    QuestionOn Vc++ Pinmembervijay71739-Feb-07 3:17 
    Generalget rid of the Init() required to be called for initialization PinmemberzikTronics26-Dec-06 3:31 
    Questionwho will send notification? PinsussAnonymous17-Feb-03 15:10 
    AnswerRe: who will send notification? Pinmemberdrewpy11-Jun-03 19:12 
    GeneralTab stop for the check box PinmemberGavin Greig10-Jun-02 4:02 
    GeneralGreat Tool....Added Enable/Disable PinmemberTony Fontenot4-Jul-01 18:23 
    GeneralI have been.... a stupid man. PinmemberChristian Graus21-Mar-01 14:45 
    GeneralDisable, depending on the rectangle PinmemberAnonymous19-Mar-01 9:25 
    GeneralRe: Disable, depending on the rectangle PinmemberChristian Graus19-Mar-01 23:16 
    GeneralRe: Disable, depending on the rectangle PinmemberChristian Graus19-Mar-01 23:28 
    GeneralNice, but... PinmemberJim Koornneef14-Mar-01 4:02 
    GeneralRe: Nice, but... PinmemberChristian Graus14-Mar-01 11:13 

    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
    Web04 | 2.8.141022.2 | Last Updated 13 Mar 2001
    Article Copyright 2001 by Christian Graus
    Everything else Copyright © CodeProject, 1999-2014
    Terms of Service
    Layout: fixed | fluid