CWnd::OnEraseBkgnd

Syntax

afx_msg BOOL OnEraseBkgnd( CDC* pDC );

Parameters

pDC

Specifies the device-context object.

Remarks

Called when the CWnd background needs erasing (for example, when resized). It is called to prepare an invalidated region for painting.

This message-handler member function calls the Default member function. Override this member function in your derived class to handle the WM_ERASEBKGND message.

The Default and DefWindowProc member functions erase the background using the class background brush specified by the hbrbackground member of the class structure.

If the hbrbackground member is NULL, OnEraseBkgnd should erase the background color. OnEraseBkgnd should align the origin of the intended brush with the CWnd coordinates by first calling the CBrush::UnrealizeObject Windows function for the brush, and then selecting the brush.

Windows assumes the background should be computed by using 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.

Return Value

OnEraseBkgnd should return TRUE to erase the background; otherwise, it should return FALSE.

See Also

::UnrealizeObject, WM_ICONERASEBKGND, CWnd::Default, WM_ERASEBKGND, CBrush::FromHandle