C# 设置桌面图标后面的窗口
假设我在屏幕上的 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
本质上,您想在桌面壁纸上绘图。桌面层次结构如下所示:
实际绘制桌面图标的是
SysListView32
,所以这就是您必须挂钩的内容。而且你不能只是把你的表格粘在上面;你必须抓住一个 WindowDC 到该句柄并在 DC 上绘图。它可以完成 - 它已经完成,但您将使用大量互操作。忘记使用传统的 Winforms 表单来执行此操作。我认为我什至没有见过它在 C# 中完成,尽管有人在 python,如果有帮助的话。我自己不是 python 编码员,但代码非常简短且易于理解。
Essentially you want to draw on the desktop wallpaper. The desktop hierarchy looks like this:
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 aWindowDC
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.
这个问题有一个解决方案,至少对于 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.
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
无论如何,我怀疑这可能可以做到,但是否应该是另一个问题。
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
Anyway, I suspect that it probably CAN be done, but whether you should is another question.