Question

I need to create a custom dialog in mfc which has a different appearance than the usual MFC dialogs.For example the color should be blue, the style etc. Is it possible? How can I do this?

Was it helpful?

Solution

I googled the background color:
See 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;
}'
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top