2013-03-14 370 views
0

我需要在mfc中創建一個自定義對話框,其外觀與通常的MFC對話框不同。例如,顏色應該是藍色,樣式等等。是否有可能?我怎樣才能做到這一點?以mfc創建自定義對話框

回答

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; 
}'