OnEraseBkgnd(pDC)返回true与返回false的区别是什么?

解决方案 »

  1.   

    返回TRUE意思是本函数已经绘好背景,不需要系统重绘背景.可以有效防窗口闪烁.
      

  2.   

    MSDN描述如下:
    WM_ERASEBKGND Notification--------------------------------------------------------------------------------The WM_ERASEBKGND message is sent when the window background must be erased (for example, when a window is resized). The message is sent to prepare an invalidated portion of a window for painting. Syntax
    WM_ERASEBKGND    WPARAM wParam
        LPARAM lParam;
        
    ParameterswParam
    Handle to the device context. 
    lParam
    This parameter is not used. 
    Return ValueAn application should return nonzero if it erases the background; otherwise, it should return zero. 
    ResThe DefWindowProc function erases the background by using the class background brush specified by the hbrBackground member of the WNDCLASS structure. If hbrBackground is NULL, the application should process the WM_ERASEBKGND message and erase the background. An application should return nonzero in response to WM_ERASEBKGND if it processes the message and erases the background; this indicates that no further erasing is required. If the application returns zero, the window will remain ed for erasing. (Typically, this indicates that the fErase member of the PAINTSTRUCT structure will be TRUE.) 
      

  3.   

    如果处理WM_ERASEBKGND消息时返回FALSE,BeginPaint标记pt.fErase 为TRUE,如果处理WM_ERASEBKGND时返回TRUE,BeginPaint标记pt.fErase为FALSE.
        如果pt.fErase标记为TRUE,指示应用程序应该处理背景,但是应用程序不一定需要处理,pt.fErase只是作为一个标记