Quantcast
Viewing all articles
Browse latest Browse all 18858

WPF Child Window Hosted in Third Party App Invisible on Windows 7 Aero Themes

I have a WPF window which has to behave as an overlay of a window in third party running application. My WPF window must be mostly transparent with some visible controls, always be positioned right on top of the other window in the z-order, move with it etc. In short: I want it to behave like a child window.

I have reviewed the techniques offered here (WPF HwndSource technique) and here (WPF SetParent technique). The HwndSource technique doesn't work at all. The SetParent technique works on Windows 7, but only with the basic theme. With Windows 7 Aero themes, it doesn't work: my child window is invisible.

I am looking for a solution that will work on all Windows 7 themes.

My test app creates a test window and calls SetParent to make it a child window of a (hard-coded HWND to) a notepad window.

Under the basic theme, it looks like so:

Image may be NSFW.
Clik here to view.
Basic Theme Child Window

Under the Windows 7 theme, I don't see it:

Image may be NSFW.
Clik here to view.
With Aero Theme - Not Working

Child Window Xaml:

<Window x:Class="WpfApplication22.TestWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="TestWindow" Height="300" Width="300" Background="#63000000" ShowInTaskbar="False" WindowStyle="None" Initialized="Window_Initialized" Loaded="Window_Loaded" AllowsTransparency="True"><Grid><Ellipse Height="87" HorizontalAlignment="Left" Margin="12,12,0,0" Name="ellipse1" Stroke="Black" VerticalAlignment="Top" Width="167" Fill="#FFBE3A3A" /></Grid></Window>

hild Window form load handler code:

var parentHwnd = new IntPtr(0x01DE0DFC); // Running notepad
var guestHandle = new WindowInteropHelper(this).Handle;

var style = WS_VISIBLE | WS_CLIPSIBLINGS | WS_CHILD | WS_POPUP;
SetWindowLong(guestHandle, GWL_STYLE, (int)(style));
SetParent(guestHandle, parentHwnd);

I've tried un-setting the WS_POPUP style, it has no effect)

Thanks

Udi



Viewing all articles
Browse latest Browse all 18858

Trending Articles