开发者

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

开发者 https://www.devze.com 2022-12-29 19:52 出处:网络
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:

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.Composition开发者_如何学CTarget.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)


I have no direct solution to your problem, but you might want to have a look at this blog post which I have read yesterday. As far as I understood, it is about a WPF wrapper framework for the needed functionality, so that you can specify all the stuff in XAML. I have not tried it, but it seems to be from guys from Microsoft, so they probably know how to do that...

0

精彩评论

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

关注公众号