C# 设置桌面图标后面的窗口

发布于 2024-08-16 11:38:29 字数 168 浏览 7 评论 0原文

假设我在屏幕上的 0,0 坐标处有一个 100px x 100px 的空表单。它没有边框样式。有什么办法可以将其放置在桌面图标后面吗?

我认为这将涉及 Progman 进程,因为它包含桌面图标。但无论我尝试什么...获取窗口句柄和更改父母等,我似乎无法让窗口出现在图标后面。

有什么想法吗?

Assume i have an empty form 100px by 100px at 0,0 coordinates on the screen. It has no border style. Is there any way to have this positioned BEHIND the desktop icons?

I would assume this would involve the process Progman because thats what contains the desktop icons. But no matter what i try... getting window handles and changing parents etc, i cant seem to get the window to appear behind the icons.

Any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

旧竹 2024-08-23 11:38:29

本质上,您想在桌面壁纸上绘图。桌面层次结构如下所示:

"Program Manager" Progman
  "" SHELLDLL_DefView
    "FolderView" SysListView32

实际绘制桌面图标的是 SysListView32,所以这就是您必须挂钩的内容。而且你不能只是把你的表格粘在上面;你必须抓住一个 WindowDC 到该句柄并在 DC 上绘图。

可以完成 - 它已经完成,但您将使用大量互操作。忘记使用传统的 Winforms 表单来执行此操作。我认为我什至没有见过它在 C# 中完成,尽管有人在 python,如果有帮助的话。我自己不是 python 编码员,但代码非常简短且易于理解。

Essentially you want to draw on the desktop wallpaper. The desktop hierarchy looks like this:

"Program Manager" Progman
  "" SHELLDLL_DefView
    "FolderView" SysListView32

It's the SysListView32 that actually draws the desktop icons, so that's what you have to hook. And you can't just stick your form on top of it; you have to grab a WindowDC to that handle and draw on the DC.

It can be done - it has been done, but you're going to be using a lot of interop. Forget about doing this with a traditional Winforms Form. I don't think I've even seen it done in C#, although somebody did it in python, if that helps. I'm not a python coder myself, but the code is pretty short and easy to understand.

白日梦 2024-08-23 11:38:29

这个问题有一个解决方案,至少对于 Windows 8 来说是这样。我将其以文章的形式发布在 CodeProject 上,因此您可以在这里阅读:

http://www.codeproject.com/Articles/856020/Draw-behind-Desktop-Icons-in-Windows

这个适用于简单绘图、Windows 窗体、wpf、directx 等。该文章中介绍的解决方案仅适用于 Windows 8。

There is a solution to this problem, at least for Windows 8. I postet it in form of an article on CodeProject, so you can read about it here:

http://www.codeproject.com/Articles/856020/Draw-behind-Desktop-Icons-in-Windows

This works for simple drawing, windows forms, wpf, directx, etc. The solution presented in that article is only for Windows 8.

美人迟暮 2024-08-23 11:38:29

Google-fu 引导我找到这个 MSDN 论坛问题:

http://social.msdn.microsoft.com/Forums/en/winformsdesigner/thread/c61d0705-d9ec-436a-b0a6-6ffa0ecec0cc

这是一篇关于使用 GetDesktopWindow 的主要陷阱的博客文章( )或处理桌面句柄(根据您的其他问题:C# Position Window On Desktop)

http://blogs.msdn.com/oldnewthing/存档/2004/02/24/79212.aspx

您也不想将 GetDesktopWindow() 作为 hwndParent 传递。如果您创建一个父窗口为 GetDesktopWindow() 的子窗口,则您的窗口现在将粘附到桌面窗口。如果您的窗口随后调用诸如 MessageBox() 之类的内容,那么这就是一个模式对话框,然后上面的规则就会生效,桌面将被禁用,并且机器将被烘烤。

无论如何,我怀疑这可能可以做到,但是否应该是另一个问题。

Google-fu led me to this MSDN forum question:

http://social.msdn.microsoft.com/Forums/en/winformsdesigner/thread/c61d0705-d9ec-436a-b0a6-6ffa0ecec0cc

And this is a blog post regard the major pitfalls with using GetDesktopWindow() or dealing with the desktop handle (as per your other question: C# Position Window On Desktop)

http://blogs.msdn.com/oldnewthing/archive/2004/02/24/79212.aspx

You also don't want to pass GetDesktopWindow() as your hwndParent. If you create a child window whose parent is GetDesktopWindow(), your window is now glued to the desktop window. If your window then calls something like MessageBox(), well that's a modal dialog, and then the rules above kick in and the desktop gets disabled and the machine is toast.

Anyway, I suspect that it probably CAN be done, but whether you should is another question.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文