How to determine frame size when processing WM_GETMINMAXINFO

I have a WPF application that processes WM_GETMINMAXINFO to configure chrome windows and still respect the system taskbar. That is, when you enlarge the window on the monitor using the taskbar on it, it will not close the taskbar. This works fine, except that the window frame is still visible at maximum magnification, which is both ugly and useless, because the window cannot be resized when it is maximized anyway.

To handle this, I decided that I needed to change the processing of WM_GETMINMAXINFO to increase the window size as follows:

 var monitorInfo = new SafeNativeMethods.MONITORINFO { cbSize = Marshal.SizeOf(typeof(SafeNativeMethods.MONITORINFO)) }; SafeNativeMethods.GetMonitorInfo(monitor, ref monitorInfo); var workArea = monitorInfo.rcWork; var monitorArea = monitorInfo.rcMonitor; minMaxInfo.ptMaxPosition.x = Math.Abs(workArea.left - monitorArea.left); minMaxInfo.ptMaxPosition.y = Math.Abs(workArea.top - monitorArea.top); minMaxInfo.ptMaxSize.x = Math.Abs(workArea.right - workArea.left); minMaxInfo.ptMaxSize.y = Math.Abs(workArea.bottom - workArea.top); // increase size to account for frame minMaxInfo.ptMaxPosition.x -= 2; minMaxInfo.ptMaxPosition.y -= 2; minMaxInfo.ptMaxSize.x += 4; minMaxInfo.ptMaxSize.y += 4; 

It really works, but my concern is the last four lines, where I assume the frame width is 2 pixels. Is there a more general approach to getting the frame width, so can I put it in my WM_GETMINMAXINFO handler?

thanks

+4
source share
1 answer

Sertak called me in the right direction by specifying the GetSystemMetrics Win32 API. This reminded me of the WPF SystemParameters class in which I found the FixedFrameHorizontalBorderHeight and FixedFrameVerticalBorderWidth . This is exactly what I need:

 // increase size to account for frame minMaxInfo.ptMaxPosition.x -= (int)SystemParameters.FixedFrameVerticalBorderWidth; minMaxInfo.ptMaxPosition.y -= (int)SystemParameters.FixedFrameHorizontalBorderHeight; minMaxInfo.ptMaxSize.x += (int)(SystemParameters.FixedFrameVerticalBorderWidth * 2); minMaxInfo.ptMaxSize.y += (int)(SystemParameters.FixedFrameHorizontalBorderHeight * 2); 
+3
source

Source: https://habr.com/ru/post/1344259/


All Articles