// TODO: Change any attributes of the DC here switch(nCtlColor) { case CTLCOLOR_DLG: return (HBRUSH)m_bkcolor.GetSafeHandle(); } // TODO: Return a different brush if the default is not desired return CDialog::OnCtlColor(pDC,pWnd,nCtlColor); } 或者 在CYourApp的InitInstance()中 SetDialogBkColor(...);就OK了
BOOL CYourDlg::OnEraseBkgnd(CDC* pDC)
{
CBrush brush;
CRect rect;
COLORREF rgbBackGnd = RGB(100,100,100);
GetClientRect(&rect);
brush.CreateSolidBrush(rgbBackGnd);
pDC->FillRect(rect,&brush);
return TRUE;
}
选择不同的RGB的值,显示不同的背景色.
如
HBRUSH CYourDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
// TODO: Change any attributes of the DC here
switch(nCtlColor)
{
case CTLCOLOR_DLG:
return (HBRUSH)m_bkcolor.GetSafeHandle();
}
// TODO: Return a different brush if the default is not desired
return CDialog::OnCtlColor(pDC,pWnd,nCtlColor);
}
或者
在CYourApp的InitInstance()中
SetDialogBkColor(...);就OK了
然后在运行的时候放任何图片都可以啊.相怎么办就怎么办吧.
在工程里加入一个bitmap资源MR_BITMAP1
重载OnEraseBackgrd;
CMyDlg::OnEraseBackgrd()
{
CBitmap bmp;
bmp.LoadBitmap(MR_BITMAP1);
CDC *pdc,memdc;
pdc=GetDC();
memdc.CreateCompatibleDC(pdc);
memdc.SelectObject(&bmp);
pdc->Bitblt(0,0,Width,Height,&memdc,0,0,Width,Height,SRCCOPY); //Width,Height是你想画的宽和高,把它设为图像的宽,高就行了
}