|
#if !defined(AFX_CHECKABLEGROUPBOX_H__BBBAE5EC_53CC_47CE_A858_4E7E7C24DDF1__INCLUDED_)
#define AFX_CHECKABLEGROUPBOX_H__BBBAE5EC_53CC_47CE_A858_4E7E7C24DDF1__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// CheckableGroupBox.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// CCheckableGroupBox window
/**
* Lots of time we want to disable a set of controls in our dialog.
* Group box is a good control to categorise a few controls together, but unfortunately
* it cannot enable/disable his controls. I extended CButton class and made it very
* simple to accomplish and it is encapsulated into one class.
*
* So you can change the title of a group box into a check box or radio button
* ( then you need more group box of course).
*
* I must confess I borrowed some idea of other talented programmers.
*
* How to use it
*
* 1. Draw a group box in resource editor as usually.
* 2. Add a member variable for this added group box, but choose CCheckableGroupBox as
* control type.
* 3. In OnInitDialog(), call m_yourVariable.SetTitleStyle(BS_AUTOCHECKBOX); to change normal
* title to a check box, or use BS_AUTORADIOBUTTON for radio box.
* 4. If you want a group of group box toggle by radio box title, just create more Checkable group box
* as you already did, and call SetGroupID to give them a group!
* 5. and that's ALL!
*/
class CCheckableGroupBox : public CButton
{
DECLARE_DYNAMIC(CCheckableGroupBox)
// Construction
public:
CCheckableGroupBox();
// Attributes
public:
void SetTitleStyle(UINT style = BS_AUTOCHECKBOX);
int GetCheck() const;
void SetCheck(int nCheck);
void SetGroupID(UINT nGroup);
UINT GetGroupID() const;
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CCheckableGroupBox)
//}}AFX_VIRTUAL
// Implementation
public:
virtual ~CCheckableGroupBox();
// Generated message map functions
protected:
//{{AFX_MSG(CCheckableGroupBox)
//}}AFX_MSG
afx_msg void OnClicked() ;
DECLARE_MESSAGE_MAP()
CButton m_TitleBox;//Could be check box or radio box
UINT m_nGroupID;//Radio button holds same group id.
void CheckGroupboxControls();
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_CHECKABLEGROUPBOX_H__BBBAE5EC_53CC_47CE_A858_4E7E7C24DDF1__INCLUDED_)
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
I have over 13 Years IT industry experience as Principle/Senior Programmer. I am experienced in .NET/J2EE system design and detailed implementation. I master UML modelling and OO design methodology with a strong C#/C++/Java coding background. I have been in working/managing a distributed project using Agile/Waterfall approach. My business knowledge includes Telecommunication, Financial Investment/Trading, and Banking.