BlackOverlord
BlackOverlord

Reputation: 398

WPF and WIndows 10. Invisible border around windows?

When i tried to align my window by side or corner of display, i discovered that there are some kind of padding between edge of screen and edge of my window. I had created new wpf project from template, added only two lines in constructor and got this:



Why it don't fit to the edge of screen? Same problem when i try to put window to the right bottom corner like this:

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

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

Of cource i can set Left property to -7, but it is not a solution. How can i properly set window place, so that it will look well on both win7 and win10?

Upvotes: 11

Views: 4064

Answers (2)

mikew
mikew

Reputation: 1734

The resizable border on the left/right/bottom is now invisible on Windows 10, and that border is where that gap is. If you put the window in the middle of the screen, and drag your mouse to the left edge of the window, you will see the cursor change to a resizing cursor for 8 pixels further out past the edge of the window. That tells you that the border still exists.

You can get the offests by using a combination of the normal GetWindowRect function and the use of the DwmGetWindowAttribute function, together with the DWMWA_EXTENDED_FRAME_BOUNDS parameter.

Upvotes: 9

CmdrKeene
CmdrKeene

Reputation: 131

They leave the metrics the same (for example, the PaddedBorderWidth in the registry is still -60), and achieve the clear resize handles entirely in the theme ("Aero"). It's not glass, it's just outright invisible the way Office 2013 renders them. Your application will literally draw at the same pixel coordinates on both Windows 7 and 10, only Windows 7 will have glass effects filling that gap.

Upvotes: 0

Related Questions