改变背景颜色:
1、在app的初始化函数中调用:
void SetDialogBkColor( COLORREF clrCtlBk = RGB(192, 192, 192), COLORREF clrCtlText = RGB(0, 0, 0) );
2、在OnCtlColor中:
if(nCtlColor == CTLCOLOR_DLG)
{
CBrush *brush;
brush = new CBrush(RGB(221,221,221));
return (HBRUSH)(brush->m_hObject);
}
设置背景位图:
CBitmap m_bmpBackground;
m_bmpBackground.LoadBitmap(IDB_BACKGROUND);
OnPaint()
{
CBkDialog::OnPaint();
/*
CPaintDC dc(this); //对话框的dc
CDC dcMem;
dcMem.CreateCompatibleDC(&dc); //创建与对话框dc兼容的内存dc
CRect rect;
GetClientRect(&rect);
BITMAP bitMap;
m_bmpBackground.GetBitmap(&bitMap);
CBitmap *pbmpOld=dcMem.SelectObject(&m_bmpBackground); //将背景位图选入内存dc中
dc.StretchBlt(0,0,rect.Width(),rect.Height(),&dcMem,0,0,bitMap.bmWidth,bitMap.bmHeight,SRCCOPY); //将内存dc中的位图拉伸显示在对话框的dc中
//dc.BitBlt(0,0,rect.Width(),rect.Height(),&dcMem,0,0,SRCCOPY);
}