首先给要加载背景的窗口添加WM_ERASEBKGND消息响应函数OnEraseBkgnd。代码如下:
点击(此处)折叠或打开
- BOOL CDlgMain::OnEraseBkgnd(CDC* pDC)
- {
- // TODO: 在此添加消息处理程序代码和/或调用默认值
- CImage image;
- image.Load(_T("./res/top.png"));
- image.Draw(pDC->m_hDC,0,0,image.GetWidth(),image.GetHeight());
- //ReleaseDC(pDC);
- return TRUE;
- //return CDialog::OnEraseBkgnd(pDC);
- }