(还需要修改!!)
The framework calls this member function when the CWnd object background needs erasing (for example, when resized).
afx_msg BOOL OnEraseBkgnd( CDC* pDC );
It is called to prepare an invalidated regionfor painting.
The default implementation erases the background using the window class background brush specified by thehbrBackground member of the window class structure.
(缺省的实现使用窗口类结构中hbrBackground成员指定的窗口类背景刷子擦除窗口背景。)
If the hbrBackground member is NULL, your overridden version ofOnEraseBkgnd should erase the background color. Your version should also align the origin of the intended brush with theCWnd coordinates by first calling UnrealizeObject for the brush, and then selecting the brush.
An overridden OnEraseBkgnd should return nonzero in response toWM_ERASEBKGND if it processes the message and erases the background; this indicates that no further erasing is required. If it returns 0, the window will remain marked as needing to be erased. (Typically, this means that thefErase member of the PAINTSTRUCT structure will beTRUE.)
Windows assumes the background is computed with the MM_TEXT mapping mode. If the device context is using any other mapping mode, the area erased may not be within the visible part of the client area.
Note: This member function is called by the framework to allow your application to handle a Windows message. The parameters passed to your function reflect the parameters received by the framework when the message was received. If you call the base-class implementation of this function, that implementation will use the parameters originally passed with the message and not the parameters you supply to the function. |
问: OnEraseBkgnd函数中返回TRUE或FALSE有什么区别?
默认的函数
BOOL CdirectUITestDlg::OnEraseBkgnd(CDC* pDC) { return CDialog::OnEraseBkgnd(pDC); }
如果改为下面代码,则绘制背景为白色。
BOOL CdirectUITestDlg::OnEraseBkgnd(CDC* pDC)
{
//return CDialog::OnEraseBkgnd(pDC);
return true;
}