用GetDesktopWindow(VOID)获得桌面窗口的局柄或指针。
然后产生相应的DC,就可以画桌面窗口了。
试试!

解决方案 »

  1.   

    HWND hDesk=::GetDesktopWindow();    //得到桌面窗口句柄
    HWND hWallPaper=::GetDlgItem(hDesk,1);    //得到"墙纸"ListView窗口句柄
    HDC hWallPaperDC=::GetDC(hWallPaper);在hWallPaperDC上画就可以了,需要重绘的时候有Hook
      

  2.   

    panda_w
    在桌面上的些操作已经成功了,谢谢!
    能否吧重画的方法说的详细点吗??
      

  3.   

    我来给你看一段:
    TCHAR str[60]="如何对Desktop进行写操作!";
    //strcat(str,zonghe[webfreq]);
    HDC hdc = ::GetDC(HWND_DESKTOP);
    //CFont font;
    HFONT font= ::CreateFont(
    24,  // logical height of font
    24,  // logical average character width
    0,  // angle of escapement
    0,  // base-line orientation angle
    FW_BOLD,  // font weight
    FALSE,  // italic attribute flag
    FALSE, // underline attribute flag
    FALSE, // strikeout attribute flag
    DEFAULT_CHARSET,  // character set identifier
    OUT_CHARACTER_PRECIS,  // output precision
    CLIP_DEFAULT_PRECIS,  // clipping precision
    DEFAULT_QUALITY,    // output quality
    FF_DECORATIVE,  // pitch and family
    "Arial"  // pointer to typeface name string
    );
    SelectObject(
    hdc,      // handle to device context
    font  // handle to object
    );
    SetBkMode(hdc,TRANSPARENT);
    SetTextColor(hdc,RGB(255,0,0));
    TextOut(hdc,100,100,str,strlen(str));
    DeleteObject(font);
      

  4.   

    To NiceFeather:
    你的程序很好用,可是如何把字写到桌面的背景上。就是说其他的程序挡住桌面时不要把字写到该程序所占用的窗体上。
      

  5.   

    HDC hdc = ::GetDC(HWND_DESKTOP);
    貌似有理,实为无稽;HWND_DESKTOP是SDK为CreateWindow定义的一个特殊值,只是碰巧HWND_DESKTOP==0罢了。
    上面的做法完全就是
    HDC hdc = ::GetDC(NULL);
    一厢情愿的伪专业写法,能蒙人!
    甚至可以写成GetDC(S_OK) / GetDC(HWND_TOP) / GetDC(WM_NULL) ...等等,可笑可笑!同意Robert2001说的::GetDC(NULL);得到就是屏幕的DC!当然会在"其他的程序挡住桌面时...把字写到该程序所占用的窗体上"了!
    这个问题我不太清楚有没有正解,但
    GetDesktopWindow() 然后 GetWindowDC() 要好得多,至少不会画到别人头上。
      

  6.   

    to newx:
    讲得有道理!深刻!我当时倒没想到这些,谢谢!to Bill1212:
    明白了newx的意思了吗?请改动一下第三句……
      

  7.   

    HDC hdc=::GetDC(NULL)
    可以在桌面上写,但刷新后就恢复了!
      

  8.   

    To NiceFeather and newx:
    GetDeskTopWindow()和GetWindowDC()来画,还是画到别人头上了, 如下:
    HWND hDesk=::GetDesktopWindow();    //得到桌面窗口句柄
    HWND hWallPaper=::GetDlgItem(hDesk,1);    //得到"墙纸"ListView窗口句柄
    TCHAR str[60]="如何对Desktop进行写操作!";
    //strcat(str,zonghe[webfreq]);
    HDC hdc = ::GetWindowDC(hDesk); //或HDC hdc = ::GetWindowDC(hWallPaper); 
    //CFont font;
    HFONT font= ::CreateFont(
    24,  // logical height of font
    24,  // logical average character width
    0,  // angle of escapement
    0,  // base-line orientation angle
    FW_BOLD,  // font weight
    FALSE,  // italic attribute flag
    FALSE, // underline attribute flag
    FALSE, // strikeout attribute flag
    DEFAULT_CHARSET,  // character set identifier
    OUT_CHARACTER_PRECIS,  // output precision
    CLIP_DEFAULT_PRECIS,  // clipping precision
    DEFAULT_QUALITY,    // output quality
    FF_DECORATIVE,  // pitch and family
    "Arial"  // pointer to typeface name string
    );
    SelectObject(
    hdc,      // handle to device context
    font  // handle to object
    );
    SetBkMode(hdc,TRANSPARENT);
    SetTextColor(hdc,RGB(255,0,0));
    TextOut(hdc,10,10,str,strlen(str));
    DeleteObject(font);