There is a window (form). Starting with win7 (maybe whists) there is such a function as maximize the window. Those. as a result, the shape will remain the same width, but it will occupy the maximum allowed height dimensions.

How to expand the form programmatically in height, i.e. put in the 0th position on Y and give it the maximum height (before start)? Is there a special feature? Actually the problem of height to find out. :)

    1 answer 1

    See it.

    You need to start to find out the necessary height. It, of course, depends on which monitor your window is on. For the main monitor, the height can be obtained simply as SystemParameters.PrimaryScreenHeight ( SystemParameters still has many useful properties, look, it may be useful). In this case, you will have to ensure the launch of the application on the main monitor.

    Or you can bypass all monitors (or if your window is already on the screen, find out which monitor it is on), as advised here (through the functionality of WinForms Screen.FromHandle or Screen.AllScreens ) and find out the height of the desired monitor.

    Great, we have a height. Now there are two strategies: “attach” the window (as in maximize mode) or allow resizing (as in Vista / Windows 7). For the second option, you simply set the Y-position to 0 and the height to the desired value (it may also be necessary to correct X also so that the window completely moves to the selected monitor). If you want to attach, try setting the Binding in the manner described here . (This code monitors window size changes and updates the height automatically.)

    • Thanks :) helped. Used [SystemParameters.FullPrimaryScreenHeight] [1]> Gets the height (in points) of the client area for the full-screen window on the main monitor. I decided not to bother with multiple screens) [1]: msdn.microsoft.com/ru-ru/library/… - IVsevolod
    • You are welcome! - VladD