开发者

.Net/Winforms, Dual monitor - Borderless Window - Maximizing doesn't work

I have a question that were not answered on

http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/fa521007-f317-48f1-9cdd-de2dbcb17aa8

(last posts are my posts). StackOverflow is better forum so could you help me :)

Briefly:

  • dual monitor configuration, primary monitor on right has lower resolution, on left side monitor with higher resolution (lo: 1280x1024; hi: 1680x1050). When maximizing on bigger one, window is larger than monitor (works only on left monitor)
  • working on a borderless window base class
  • maximize to the actual client area does not work as expected. Solved by adding a WndProc hook and fiddling with the size parameters. Multiple monitor support added some issues, because maximizing seems to rely on MaxTrackSize instead of MaxSize. This seems to happen only when the primary monitor is smaller than the second monitor

Something I found in specification:

http://msdn.microsoft.com/en-us/libra开发者_如何学Cry/ms632605(v=VS.85).aspx

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 if I understand correctly in my case it is impossible to maximize on screen with higher resolution when there is taskbar placed in the way not to hide it under maximized window?

Cheers, jbk


You can implement your own "maximize":

  1. Determine which screen your form resides on with Screen.FromControl
  2. Set the offset and size of your Formaccording to the screen's offset and size.
  3. You can use either use the WorkingArea(the desktop area) or the Bounds(the whole screen with the toolbars) of the Screen as required.

*If you want to hide the toolbars and be defacto "full screen", i think you will need to set the form as TopMost.


This is what worked for me:

  1. Set FormBorderStyle to FixedSingle - might also work with other styles != None, haven't tested that...
  2. Set WindowState to FormWindowState.Maximized
  3. Reset FormBorderStyle to None

At least, it works for pure WinForms stuff without resorting to WinAPI

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜