I have an MDI app - and I wanted a less boring backdrop. The trick is to subclass the MDI Frame window - and then override WM_ERASEBKGND. The below code uses CSubclassWnd by Paul DiLascia - you should be able to search for in from an old MSJ article on the web. Good luck, Iain.
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
m_Backdrop.Install (m_hWndMDIClient, IDB_MIDAS, 32);
....
return 0;
}
class CUIMDIBackdrop : public CSubclassWnd
{
public:
CUIMDIBackdrop ();
~CUIMDIBackdrop ();
BOOL Install (HWND hWndMDIClient, UINT idBitmap, int nMargin);
protected:
virtual LRESULT WindowProc(UINT msg, WPARAM wp, LPARAM lp);
};
CUIMDIBackdrop::CUIMDIBackdrop ()
{
}
CUIMDIBackdrop::~CUIMDIBackdrop ()
{
}
BOOL CUIMDIBackdrop::Install (HWND hWndMDIClient, UINT idBitmap, int nMargin)
{
// load resources and other graphics stuff here
return HookWindow (hWndMDIClient);
}
LRESULT CUIMDIBackdrop::WindowProc(UINT msg, WPARAM wp, LPARAM lp)
{
if (msg != WM_ERASEBKGND)
return CSubclassWnd::WindowProc(msg, wp, lp);
HDC hDC = (HDC) wp;
CDC \*pDC = CDC::FromHandle (hDC);
CRect rc;
::GetClientRect (m\_hWnd, &rc);
// do pretty stuff here
return TRUE;
}