Trouble with creating WPF window extended on the title area (like Office 2007/2010)

Posted by Rikker Serg on Stack Overflow See other posts from Stack Overflow or by Rikker Serg
Published on 2010-05-12T05:20:10Z Indexed on 2010/05/12 5:24 UTC
Read the original article Hit count: 259

Filed under:
|
|

I want to make WPF window extended on the title area (like Office 2007/2010). I implemented DwmWindow (see DwmTest.zip) where I put required stuff. Commonly, it works fine except one disgusting thing: the window appears as white rectangle (see DwmIssue.png) and after a few second this rectangle disappears and the content of the window is shown (see DwmIssueCorrect.png). This bug is essential only for my window. If I remove this lines it works fine (without it aero will not showed on title):

HwndSource mainWindowSrc = HwndSource.FromHwnd(handle);
if (mainWindowSrc != null) mainWindowSrc.CompositionTarget.BackgroundColor = Colors.Transparent; 
NativeMethods.MARGINS margins = new NativeMethods.MARGINS(0, 50, 0, 0);
NativeMethods.DwmExtendFrameIntoClientArea(handle, margins);

How can I eliminate this white rectangle?

(To run a sample DwmTest.zip WinVista/7 with DWM enabled and .NET 4.0 is required. To compile sample you will need Visual Studio 2010)

© Stack Overflow or respective owner

Related posts about wpf

Related posts about c#