无法在DesktopWindow上绘制 [英] Failed to draw on DesktopWindow

查看:67
本文介绍了无法在DesktopWindow上绘制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用 GetDC(GetDesktopWindow)在桌面"窗口上绘制任何内容,例如以下简单程序:

I've tried to draw any thing on Desktop window using GetDC(GetDesktopWindow), like the following simple program:

#include <windows.h>

int main()
{
    TextOut(GetDC(GetDesktopWindow()), 10, 10, TEXT("Test TextOut Tester!!"), 21);
    return 0;
}

似乎我当前的用户权限会影响绘图行为,我不是PC上的管理员,这是为什么吗?是否有任何有关此问题的文档?预先感谢

It seems that my current user privileges affect the drawing behavior, I am not admin on my PC, is this the reason for that? is there any documentation for this issue ? Thanks in advance

推荐答案

像这样无法在桌面窗口上绘制的简单原因是您实际上无法看到桌面窗口.从Windows 95开始,桌面窗口已完全被资源管理器拥有的一堆Windows所遮盖.

The simple reason you can't draw on the desktop window like this is you cannot actually see the desktop window. Since Windows 95 the desktop window has been completely obscured by a cluster of windows owned by explorer.

调用 GetDC(GetDesktopWindow())时获得的DC将因此被完全裁剪.

The DC you get when you call GetDC(GetDesktopWindow()) will thus be completely clipped.

如果要直接在显示器上绘制,则 GetDC(NULL)将为您提供DC,可用于在桌面和可见窗口上绘制所有图形.但是,正如已经提到的那样,它将完全在Windows的重绘逻辑之外运行,并且结果将非常丑陋且不适合任何实际目的(例如,从无窗应用程序中获取某种调试反馈除外)在开发过程中).

If you want to draw directly on the display GetDC(NULL) will give you a DC that you can use to draw all over the desktop and visible windows. But that, as has been mentioned, will be operating entirely outside Windows' repainting logic and the results will be, well, ugly and unsuited to any real purpose (other than, say, getting some kind of debug feedback from a windowless app you are in the process of developing).

大多数想要执行在桌面上显示内容"的应用程序都是通过创建窗口并在其上绘制来实现的.为什么在这里不合适呢?

Most applications that want do "display something on the desktop" do so by creating a window and drawing on that. Why is that not appropriate here?

这篇关于无法在DesktopWindow上绘制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆