Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

CCheckStatic

0.00/5 (No votes)
12 Mar 2001 1  
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

    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