The docs for the ptMaxSize
and ptMaxPosition
components of MINMAXINFO
say:
For top-level windows, this value is based on (...) the primary monitor.
Raymond Chen elaborates:
If the specified size is greater than or equal to the size of the primary monitor, then the
ptMaxSize
is adjusted to include the difference in size between the primary monitor and the actual monitor. (...) But ifptMaxSize
does not completely cover the monitor, then its value is used as-is.
So, if I want to fill out MINMAXINFO
such that a window maximised to a nonprimary monitor, in a setup with a primary monitor of a different resolution / orientation, fills the work area, but without overlapping the taskbar if that happens to be on the same monitor... how do I reliably do that?
ISTM that, once I've obtained the work area dimensions for the monitor the window is on and calculated the desired window max size:
- if the primary monitor is the same width or wider than the work area, I can leave the width alone
- otherwise, if the window is wider than the monitor it is on, I can subtract the difference between the monitor widths
- otherwise, I have no means of describing the width I want
...and the same for height.
If I code that up, I do get exactly the described behaviour... except in the case where the monitors have the same resolution but different orientation, where the adjustment doesn't seem to get applied.
This all seems incredibly convoluted and odd. Am I missing or misunderstanding something? Is there actually some simple robust calculation I should be doing instead?