开发者

Attaching a WPF window to the Desktop

开发者 https://www.devze.com 2023-03-09 07:20 出处:网络
I have created a WPF applica开发者_JS百科tion that has no chrome and a transparent background WindowStyle=\"None\" AllowsTransparency=\"True\"

I have created a WPF applica开发者_JS百科tion that has no chrome and a transparent background

WindowStyle="None" AllowsTransparency="True"

IntPtr windowHandle = new WindowInteropHelper(window).Handle;
IntPtr oldParent = SetParent(windowHandle, desktopHandle);

But whenever i try to set this window to be a child of the desktop process (So that it isn't affected by "Show Desktop" commands) it stops drawing. If i change AllowsTransparency back to False it works as expected, however I do want it to be transparent and have no borders.

Can anyone give me any suggestions on how to make this work correctly? I can get this to work by using the same method in a Winforms application.


I suspect that the reason it worked for Winforms and not for WPF is that Winforms uses GDI for rendering and WPF uses DirectX. These technologies have interoperability issues that are more fully detailed here, in particular in a section called "Transparency and Top-Level Windows".

http://msdn.microsoft.com/en-us/library/aa970688.aspx

You might be able work around the issue by hosting the WPF visual in a Win32 window, as detailed here:

http://msdn.microsoft.com/en-us/library/ms742522.aspx#hosting_a_wpf_page

0

精彩评论

暂无评论...
验证码 换一张
取 消