I have a multi monitor setup. When a window is maximized on secondary monitor, I need to restrict the maximum size and position.
In MSDN, the documentation for MINMAXINFO
mentions the following:
For systems with multiple monitors, the ptMaxSize and ptMaxPosition members describe the maximized size and position of the window on the primary monitor, even if the window ultimately maximizes onto a secondary monitor. In that case, the window manager adjusts these values to compensate for differences between the primary monitor and the monitor that displays the window. Thus, if the user leaves ptMaxSize untouched, a window on a monitor larger than the primary monitor maximizes to the size of the larger monitor.
So, I tried restriction by doing SetWindowPos
in OnSysCommand
if nId
is SC_MAXIMIZE
. It works, when the user clicks on maximize button/double click the title bar.
But, when the user uses Win+Up Arrow key or move the window to top of monitor to maximize, I am not able to handle the maximize restriction.
So, is there any common place to handle my all scenarios?
Is there any way to do trick on receiving WM_GETMINMAXINFO
message.
I know this post is old, but I wish to share my code for those who still need a solution.