WPF and WIndows 10. Invisible border around windows?

When I tried to align the window about me or in the corner of the screen, I found that there was some kind of gasket between the edge of the screen and the edge of the window. I created a new wpf project from the template, added only two lines in the constructor and got the following:

TW1de.png

Why doesn't it come to the edge of the screen? Same issue when I try to put a window in the lower right corner as follows:

Rect workArea = SystemParameters.WorkArea; Left = workArea.Location.X + workArea.Width - Width; Top = workArea.Location.Y + workArea.Height - Height; 

It looks like the window has a 7px border (like on win7), but invisible on win10. I also found that if I set both WindowStyle and WindowStyle.None and ResizeMode to ResizeMode.NoResize , the system correctly places the window, but this is not what I need. On win7, the same program works as expected.

From the course, I can set the Left property to -7, but this is not a solution. How can I set the window correctly so that it looks good on both win7 and win10?

+6
source share
2 answers

The changed border left / right / bottom is now invisible for Windows 10, and this border is that gap. If you place the window in the middle of the screen and drag the mouse to the left edge of the window, you will see that the cursor changes to a resize cursor 8 pixels further along the edge of the window. This suggests that the border still exists.

You can get competitions using a combination of the normal GetWindowRect function and using the DwmGetWindowAttribute function along with the DWMWA_EXTENDED_FRAME_BOUNDS parameter.

+5
source

They leave the metrics the same (for example, PaddedBorderWidth in the registry is still -60), and completely clear the size descriptors in the subject ("Aero"). This is not glass, it is just completely invisible, as Office 2013 makes them. Your application will literally draw in the same pixel coordinates on both Windows 7 and 10, only Windows 7 will have glass effects filling this gap.

+1
source

All Articles