The beta version of the MFC Feature Pack (the extension to MFC 9 from Visual Studio 2008) contains an extended dialog class implementation, CDialogEx. What this brings new, publicly, is the ability to set the background of the dialog box to a color or an image.
A first new method allows to set a background color.
void SetBackgroundColor(COLORREF color, BOOL bRepaint = TRUE);

A second overloaded method allows to set an image on the background.
void SetBackgroundImage(
HBITMAP hBitmap,
BackgroundLocation location = BACKGR_TILE,
BOOL bAutoDestroy = TRUE,
BOOL bRepaint = TRUE);
BOOL SetBackgroundImage(
UINT uiBmpResId,
BackgroundLocation location = BACKGR_TILE,
BOOL bRepaint = TRUE);
You can use it like this:
BOOL CDialogDemoDlg::OnInitDialog()
{
CDialogEx::OnInitDialog();
// ...
HBITMAP bmp = ::LoadBitmap(AfxGetResourceHandle(), MAKEINTRESOURCE(IDB_BITMAP_LOGO));
SetBackgroundImage(bmp, BACKGR_TILE);
return TRUE;
}

What is very weird is that the only styles for the image are these:
enum BackgroundLocation
{
BACKGR_TILE,
BACKGR_TOPLEFT,
BACKGR_TOPRIGHT,
BACKGR_BOTTOMLEFT,
BACKGR_BOTTOMRIGHT,
};
This implementation lacks two basic styles: Center and Stretch. I really don’t understand why they were not implemented. It’s much more likely to need an image centered or stretched that aligned at the bottom-left, for instance. Thus, I don’t see how good this class is if I have to override the entire painting myself if I need that functionality.
Here is an implementation of a dialog class that supports those styles.


















