MFC dialog maximized is larger than monitor

In WIndows 7, when I maximize an MFC dialog, using the system menu's small square button, the resulting dialog window is slightly larger than the physical dimensions of the screen. Why is this?

The GetSystemMetrics calls yield the correct monitor dimensions, and the screen resolution (right-click desktop) also shows the correct dimensions.

The WM_SIZE message, sent after the window is maximized, shows a size slightly larger than the monitor, consistent with the edge portions of the dialog being cut off. For example, on a 1920 x 1080 monitor, the maximized size from OnSize() is 1936 x 1096. Spy++ shows

Rectangle: (-1928, -8) - (8, 1088), 1936 x 1096 (Maximized)

Restored Rect: (-1188, 79) - (173, 849) 1015 x 770

Client Rect: (8, 50) - (1928, 1088) 1920 x 1038

(the dialog was on the left monitor of a 2-monitor system).

I need to understand the exact definition of "maximizing a window", because I am rearranging some dialog windows on both single- and multiple-monitor systems in response to user changing window size and/or position.

Can someone please explain why I am seeing the results I describe, and how I can set up a dialog so the system menu's "maximize" button does not cause the dialog to expand past the physical boundaries of the monitor?

MFC, 64-bit Windows 7 Pro, Visual Studio 2013, C++


When you maximize a window, the non-client border area is moved to outside of the monitor. You can see that the client area is the same as the monitor size minus the size of the title bar.

PS There's no way to modify this behavior, Windows itself is in charge of the window dimensions when maximized. You might be able to modify the window to turn off the borders on WM_SIZE or something, but then you'd lose the caption bar.

链接地址: http://www.djcxy.com/p/39242.html

上一篇: C ++

下一篇: 最大化MFC对话框比监视器大