InvalidateRect(0,NULL,0); 
这样可以刷新桌面。

解决方案 »

  1.   

    BOOL InvalidateRect(
      HWND hWnd,  // handle of window with changed update region
      CONST RECT *lpRect,
                  // address of rectangle coordinates
      BOOL bErase // erase-background flag
    );
     
    这是该函数的参数说明,
    CRect m_rect;
    ...   把m_rect设为你要刷新的区域。 
    InvalidateRect(0,m_rect,0); 
      

  2.   

    InvalidateRect(0,NULL,0); 
    是刷新整个桌面。
    试试后者,是刷新局部。
      

  3.   

    InvalidateRect(0,m_rect,0); 
    还是会抖动,而且我确定m_rect没有坐标系的问题。
    只要第一个参数为NULL,windows会重绘所有窗口。
      

  4.   

    InvalidateRect(::GetDC(NULL),m_rect,0); 
    试试
      

  5.   

    我非常想知道::GetDC(NULL)所指向的HWND,而且我刚才测试知道,不等于::GetDesktopWindow()返回的。
      

  6.   

    GetDC:
    The GetDC function retrieves a handle to a display device context for the client area of a specified window or for the entire screen. You can use the returned handle in subsequent GDI functions to draw in the device context. 
    该函数检索一指定窗口的客户区域或整个屏幕的显示设备上下文环境的句柄,以后可以在GDI函数中使用该句柄来在设备上下文环境中绘图。
     
    GetDesktopWindow:
    The GetDesktopWindow function returns a handle to the desktop window. The desktop window covers the entire screen. The desktop window is the area on top of which all icons and other windows are painted. 
    该函数返回桌面窗口的句柄。桌面窗口覆盖整个屏幕。桌面窗口是一个要在其上绘制所有的图标和其他窗口的区域。    
      

  7.   

    对不起,是我讲得不够清楚,我是指::GetDC(NULL)所得的设备上下文环境所指向的窗口,与::GetDesktopWindow()返回的HWND。表现为::GetDC(NULL) 与::GetDC(::GetDesktopWindow())所得到的HDC,我在上面绘图时效果不一样,前者有结果在整个Screen上,后者什么都没有。另外InvalidateRect()的第一个参数为HWND。
      

  8.   

    问题的关键是如何取桌面或Screen的HWND?
    请高手指点(或者用别的什么方法)。