在mfc中创建自定义对话框

时间:2013-03-14 09:01:17

标签: mfc customdialog

我需要在mfc中创建一个自定义对话框,其外观与通常的MFC对话框不同。例如,颜色应该是蓝色,样式等。有可能吗?我怎样才能做到这一点?

1 个答案:

答案 0 :(得分:1)

我用Google搜索了背景颜色:
看到 here

//CMyDlg.h
//Add a CBrush object

class CMyDlg : public CDialog
{
// Construction
    public:
    CTest2Dlg(CWnd* pParent = NULL);    // standard constructor
    CBrush  m_brush;
// Dialog Data


//initialize the brush with the desired color in the OnInitDialog() methodl  


BOOL CMyDlg::OnInitDialog()
{   
    m_brush.CreateSolidBrush(RGB(255,0,0));
    CDialog::OnInitDialog();

}

//Return the brush like this:

HBRUSH CMyDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) 
{
//  HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);

// TODO: Return a different brush if the default is not desired
    return m_brush;
}'