
Introduction
CAdvancedButton, CAdvancedEdit, and CAdvancedDialog are MFC controls respectively derived from CButton, CEdit, and CDialog.
These classes implement the CAdvancedComponent virtual class, and offer functions to change background and foreground colors.
Using the Code
To integrate the CAdvancedComponent classes into your application, please follow the steps below:
Using the CAdvancedButton
- Add AdvancedComponent.h, AdvancedButton.h, and AdvancedButton.cpp to your project.
- Include "AdvancedButton.h" in the dialog class' header.
- Declare the button in the dialog class. For example:
CAdvancedButton adBtn1;
- Initialize the button in the dialog class'
OnInitDialog function:
adBtn1.SubclassDlgItem(IDC_BUTTON1, this, RED, GREEN);
- Eventually change the draw form:
adBtn1.SetDrawType(DRAW_ELLIPSE);
- Eventually change the colors:
adBtn1.SetColors(RED);
adBtn1.SetBackGround(YELLOW);
adBtn1.SetForeGround(BLUE);
Using the CAdvancedEdit
- Add AdvancedComponent.h, AdvancedEdit.h, and AdvancedEdit.cpp to your project.
- Include "AdvancedEdit.h" in the dialog class' header.
- Declare the edit in the dialog class. For example:
CAdvancedEdit adEdit1;
- Initialize the edit in the dialog class'
OnInitDialog function:
adEdit1.SubclassDlgItem(IDC_EDIT1, this);
- Change the colors:
adEdit1.SetBackGround(YELLOW);
adEdit1.SetForeGround(BLUE);
adEdit1.SetTextBackGround(RED);
Using the CAdvancedDialog
- Add AdvancedComponent.h, AdvancedDialog.h, and AdvancedDialog.cpp to your project.
- Include "AdvancedDialog.h" in the dialog class' header.
- Replace the base class from
CDialog to CAdvancedDialog in your dialog class' header.
- In the .cpp file, in the constructor, replace
CDialog by CAdvancedDialog.
- In the .cpp file, replace
CDialog::DoDataExchange by CAdvancedDialog::DoDataExchange.
- If they exist, do the same thing for
OnInitDialog and the other inherited functions.
- In the .cpp file, replace "
BEGIN_MESSAGE_MAP(CTest, CDialog)" by "BEGIN_MESSAGE_MAP(CTest, CAdvancedDialog)".
- Use
CAdvancedDialog's functions.
If you want the CAdvancedDialog children to change automatically, create the child dialog using a pointer on the main dialog as the first parameter:
class CMyDialogClass : public CAdvancedDialog {
...
};
CMyDialogClass myDialogBow(this);
myDialogBow.DoModal();
UML class diagram

History
- November 2008: First version distributed on CodeProject.