在多屏幕环境中最大化窗口,不隐藏/阻断任务栏任务栏、窗口、环境、多屏

2023-09-05 00:18:34 作者:独伴

这是一个后大家谁曾经问自己我怎么最大限度地在我的多屏设置窗口而不阻塞任务栏。

This is a post to everyone who has ever asked himself "how do I maximize a window in my multi-screen setup without blocking the task bar".

这个问题似乎是有 MaximizeBox 和 MinimizeBox 设置为false,并且被编程最大化在多屏幕环境覆盖了整个窗口屏幕,不仅在 Screen.WorkingArea

The problem seems to be that a window that has MaximizeBox and MinimizeBox set to false and that gets maximized programmatically in a multi-screen environment covers the entire screen, not only the Screen.WorkingArea.

要最大化窗口只工作区中,人们需要利用 MaximizeBox 和 MinimizeBox 像这样的属性:

To maximize a window to the working area only, one needs to utilize the MaximizeBox and MinimizeBox properties like so:

// This code should be placed in the Form's ResizeEnd handler

MaximizeBox = MinimizeBox = true;           // Enable both boxes
WindowState = FormWindowState.Maximized;    // Set to maximized
MaximizeBox = MinimizeBox = false;          // Disable both boxes again

因此​​,该窗口将被很好地最大化在屏幕上,尊重屏幕的工作区(不阻塞任务栏)。

Thus, the window will be nicely maximized on the screen and respect the screen's working area (not block the task bar).

推荐答案

或者你可以设置this.MaximumSize为新的大小(screen.primaryscreen.bounds.width + screen.secondaryscreen.bounds.width,screen.primaryscreen.bounds。高度)。

Or you could set this.MaximumSize to new Size (screen.primaryscreen.bounds.width + screen.secondaryscreen.bounds.width, screen.primaryscreen.bounds.height).

P.S。我写这从我的手机,所以我不能检查语法等等,也是你为什么要发布此为问题?

P.S. I wrote this from my phone so I cannot check syntax etc... and also why did you post this as a 'question'?