拿基于对话框的应用程序来说,比如有一个Test的项目,在项目的应用程序类中加入下面一句话: BOOL CTestApp::InitInstance() { AfxEnableControlContainer(); // Standard initialization // If you are not using these features and wish to reduce the size // of your final executable, you should remove from the following // the specific initialization routines you do not need.#ifdef _AFXDLL Enable3dControls(); // Call this when using MFC in a shared DLL #else Enable3dControlsStatic(); // Call this when linking to MFC statically #endif CTestDlg dlg; m_pMainWnd = &dlg; SetDialogBkColor(RGB(190,190,100),RGB(0,0,0));//注意,就是这句话 int nResponse = dlg.DoModal(); if (nResponse == IDOK) { // TODO: Place code here to handle when the dialog is // dismissed with OK } else if (nResponse == IDCANCEL) { // TODO: Place code here to handle when the dialog is // dismissed with Cancel } // Since the dialog has been closed, return FALSE so that we exit the // application, rather than start the application's message pump. return FALSE; }
BOOL CPIMApp::InitInstance() { AfxEnableControlContainer(); // Standard initialization this->SetDialogBkColor(RGB(220,233,248));//设置对话框背景颜色 CPIMDlg dlg; m_pMainWnd = &dlg; int nResponse = dlg.DoModal(); if (nResponse == IDOK) { } else if (nResponse == IDCANCEL) { } // Since the dialog has been closed, return FALSE so that we exit the // application, rather than start the application's message pump. return FALSE; }
搭个车问一下: 怎么改变单文档view窗口的颜色呢?还有怎么改变单文档的工具条的颜色呢?
逍遥浪子!不行呀!显示 error C2039: 'SetDialogBkColor' : is not a member of 'CFMXL1Dlg'
//...
CRect r;
GetClientRect(&r);
Brush brush;
brush.CreateBrush(......//此处定义颜色,我在网吧,记不大清楚,你可以这样试试!
pDC->rectangle(&r);
BOOL CTestApp::InitInstance()
{
AfxEnableControlContainer(); // Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need.#ifdef _AFXDLL
Enable3dControls(); // Call this when using MFC in a shared DLL
#else
Enable3dControlsStatic(); // Call this when linking to MFC statically
#endif CTestDlg dlg;
m_pMainWnd = &dlg;
SetDialogBkColor(RGB(190,190,100),RGB(0,0,0));//注意,就是这句话
int nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
// TODO: Place code here to handle when the dialog is
// dismissed with OK
}
else if (nResponse == IDCANCEL)
{
// TODO: Place code here to handle when the dialog is
// dismissed with Cancel
} // Since the dialog has been closed, return FALSE so that we exit the
// application, rather than start the application's message pump.
return FALSE;
}
在VC7中取消了这个函数
{
AfxEnableControlContainer(); // Standard initialization this->SetDialogBkColor(RGB(220,233,248));//设置对话框背景颜色 CPIMDlg dlg;
m_pMainWnd = &dlg;
int nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
}
else if (nResponse == IDCANCEL)
{
} // Since the dialog has been closed, return FALSE so that we exit the
// application, rather than start the application's message pump.
return FALSE;
}
怎么改变单文档view窗口的颜色呢?还有怎么改变单文档的工具条的颜色呢?