class CDialogEx : public CDialog
{
public:
//改变背景颜色
void SetBackgroundColor(COLORREF color, BOOL bRepaint = TRUE);
//改变背景图片
void SetBackgroundImage(HBITMAP hBitmap, BackgroundLocation location = BACKGR_TILE, BOOL bAutoDestroy = TRUE, BOOL bRepaint = TRUE);
//改变背景图片(通过资源图片ID)
BOOL SetBackgroundImage(UINT uiBmpResId, BackgroundLocation location = BACKGR_TILE, BOOL bRepaint = TRUE);
}
//第一种
SetBackgroundColor(RGB(30, 144, 255));
//第二种
HBITMAP hBitmap;
hBitmap = (HBITMAP)LoadImageA(
AfxGetInstanceHandle(),
"00180.bmp",
IMAGE_BITMAP,
0,
0,
LR_LOADFROMFILE);
this->SetBackgroundImage(hBitmap);
//第三种
this->SetBackgroundImage(IDB_BITMAP1);
看看效果