如何修改frame窗口的背景颜色?

MDI窗口的客户区是由frame窗口拥有的另一个窗口覆盖的。为了改变frame窗口背景的颜色,只需要这个客户区的背景颜色就可以了。你必须自己处理WM_ERASEBKND消息。下面是工作步骤:

  • 创建一个从CWnd类继承的类,就叫它CMDIClient吧;
  • 在CMDIFrameWnd中加入CMDIClient变量;(具体情况看下面的代码)

#include "MDIClient.h"
class CMainFrame : public CMDIFrameWnd
{
...
protected:
CMDIClient m_wndMDIClient;
}

重载CMDIFrameWnd::OnCreateClient,下面是这段代码,请注意其中的SubclassWindow();
BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
if ( CMDIFrameWnd::OnCreateClient(lpcs, pContext) )
{
m_wndMDIClient.SubclassWindow(m_hWndMDIClient);
return TRUE;
}
else
return FALSE;
}