Work around wrong client size computation for not yet shown maximized windows.
The client size of maximized windows which hadn't been shown yet isn't computed correctly by wxMSW because WM_NCCALCSIZE returns too small values for some reason. Attempts to fix this were unsuccessful so just ensure that the window is re-laid out using the right size from WM_SIZE it receives when it is shown instead of using the wrong pending size. Closes #11762. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@64115 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -662,6 +662,16 @@ bool wxTopLevelWindowMSW::Show(bool show)
|
||||
nShowCmd = SW_HIDE;
|
||||
}
|
||||
|
||||
// we only set pending size if we're maximized before being shown, now that
|
||||
// we're shown we don't need it any more (it is reset in size event handler
|
||||
// for child windows but we have to do it ourselves for this parent window)
|
||||
//
|
||||
// make sure to reset it before actually showing the window as this will
|
||||
// generate WM_SIZE events and we want to use the correct client size from
|
||||
// them, not the size returned by WM_NCCALCSIZE in DoGetClientSize() which
|
||||
// turns out to be wrong for maximized windows (see #11762)
|
||||
m_pendingSize = wxDefaultSize;
|
||||
|
||||
DoShowWindow(nShowCmd);
|
||||
|
||||
#if defined(__WXWINCE__) && (_WIN32_WCE >= 400 && !defined(__POCKETPC__) && !defined(__SMARTPHONE__))
|
||||
@@ -671,11 +681,6 @@ bool wxTopLevelWindowMSW::Show(bool show)
|
||||
frame->GetMenuBar()->AddAdornments(GetWindowStyleFlag());
|
||||
#endif
|
||||
|
||||
// we only set pending size if we're maximized before being shown, now that
|
||||
// we're shown we don't need it any more (it is reset in size event handler
|
||||
// for child windows but we have to do it ourselves for this parent window)
|
||||
m_pendingSize = wxDefaultSize;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@@ -1819,6 +1819,18 @@ void wxWindowMSW::DoGetClientSize(int *x, int *y) const
|
||||
if ( m_pendingSize != wxDefaultSize )
|
||||
{
|
||||
// we need to calculate the client size corresponding to pending size
|
||||
//
|
||||
// FIXME: Unfortunately this doesn't work correctly for the maximized
|
||||
// top level windows, the returned values are too small (e.g.
|
||||
// under Windows 7 on a 1600*1200 screen with task bar on the
|
||||
// right the pending size for a maximized window is 1538*1200
|
||||
// and WM_NCCALCSIZE returns 1528*1172 even though the correct
|
||||
// client size of such window is 1538*1182). No idea how to fix
|
||||
// it though, setting WS_MAXIMIZE in GWL_STYLE before calling
|
||||
// WM_NCCALCSIZE doesn't help and AdjustWindowRectEx() doesn't
|
||||
// work in this direction neither. So we just have to live with
|
||||
// the slightly wrong results and relayout the window when it
|
||||
// gets finally shown in its maximized state (see #11762).
|
||||
RECT rect;
|
||||
rect.left = m_pendingPosition.x;
|
||||
rect.top = m_pendingPosition.y;
|
||||
|
Reference in New Issue
Block a user