在 Vista 上将应用程序粘贴到桌面

发布于 2024-08-03 22:13:38 字数 417 浏览 1 评论 0原文

我有一个应用程序想要粘贴到桌面上。坚持桌面意味着每次有人单击 windows+D 或显示桌面图标时,桌面上都会出现该应用程序。

用户可以在桌面上找到该应用程序并随时更改位置,但它始终保留在桌面上。

我们设法在 XP 上通过使用 winAPI 方法 SetParent (this .Handle, FindWindow ( "Progman " , null )); 将应用程序的父级设置为桌面来做到这一点。

在 Vista 上,我们设法将其粘贴到桌面上,每当桌面获得焦点时,它就会在我们的窗口周围绘制灰色背景。当我的窗口移动时,这个背景不会消失,在桌面上留下丑陋的方块。当我单击 Windows+D 时,它们全部消失。 请注意,这种情况在 XP 上根本不会发生。

该客户端基于.NET 3.0和WPF。

知道为什么会发生以及如何解决它吗?

I have an application that I want to stick to the desktop. Stick to the desktop means that every time that someone click windows+D or the show desktop icon the desktop will appear with the application on it.

The user can locate the application on the desktop and change the location at any time but it always remains on the desktop.

We manage to do it on XP by setting the application’s parent to be the desktop using the winAPI methods SetParent (this .Handle, FindWindow ( "Progman " , null ));.

On Vista we manage to stick it to the desktop, whenever the desktop gets focus, it draws a gray background around we window. this background doesn't disappear when my window is moved, leaving ugly squares on the desktop. when I click Windows+D they all vanish.
Note that this doesn't happen on XP at all.

The client is based on .NET 3.0 and WPF .

Any idea why it happens and how to solve it?

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

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

发布评论

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

评论(1

最美的太阳 2024-08-10 22:13:38

使用以下代码并将窗口句柄传递给函数,同时加载表单希望这完全解决您的问题

public void SetFormOnDesktop(IntPtr hwnd) {  
IntPtr hwndf = hwnd;  
IntPtr hwndParent = FindWindow("ProgMan", null);  
SetParent(hwndf, hwndParent);  
}

use the following code and pass the window handle to the function while form load hope fully this resolves your problem

public void SetFormOnDesktop(IntPtr hwnd) {  
IntPtr hwndf = hwnd;  
IntPtr hwndParent = FindWindow("ProgMan", null);  
SetParent(hwndf, hwndParent);  
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文