如何在Windows的桌面上绘制文本? [英] How to draw text on the desktop in Windows?

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

问题描述

如何在Windows桌面上放置文本?有人告诉我,我需要GetDesktopWindow(),但我需要一个例子。

How Would I go about placing text on the windows desktop? I've been told that GetDesktopWindow() is what I need but I need an example.

推荐答案

我假设您的最终版本目标是在桌面上显示某种状态信息。

I'm assuming your ultimate goal is displaying some sort of status information on the desktop.

您将必须执行以下操作之一:

You will have to do either:


  • 向Explorer的进程中注入一个DLL,并将其子类化为桌面窗口(在 Progman底部的 SysListView32 窗口的层次结构)直接在其上绘制文本。

  • Inject a DLL into Explorer's process and subclass the desktop window (the SysListView32 at the bottom of the Progman window's hierarchy) to paint your text directly onto it.

创建一个不可激活的窗口,其背景使用 PaintDesktop绘制并在上面涂上文字。

Create a nonactivatable window whose background is painted using PaintDesktop and paint your text on it.

第一个解决方案是最具侵入性的,而且相当

First solution is the most intrusive, and quite hard to code, so I would not recommend it.

第二种解决方案可以提供最大的灵活性。没有未记录或依赖于Explorer的特定实现,甚至不依赖于Explorer作为外壳。

Second solution allows the most flexibility. No "undocumented" or reliance on a specific implementation of Explorer, or even of just having Explorer as a shell.

为了防止将窗口带到顶部单击后,可以在Windows 2000及更高版本上使用扩展的窗口样式 WS_EX_NOACTIVATE 。在下层系统上,您可以处理 WM_MOUSEACTIVATE 消息并返回 MA_NOACTIVATE

In order to prevent a window from being brought to the top when clicked, you can use the extended window style WS_EX_NOACTIVATE on Windows 2000 and up. On downlevel systems, you can handle the WM_MOUSEACTIVATE message and return MA_NOACTIVATE.

如果您需要使用分层窗口实现真正的透明性,则可以通过 PaintDesktop 调用来解决这个问题,但是这个概念保持不变。我写了另一个答案,详细说明了如何使用GDI +使用alpha正确地处理分层窗口。

You can get away with the PaintDesktop call if you need true transparency by using layered windows, but the concept stays the same. I wrote another answer detailing how to properly do layered windows with alpha using GDI+.

这篇关于如何在Windows的桌面上绘制文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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