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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With