// Get total size
void wxWindowMSW::DoGetSize(int *x, int *y) const
{
- RECT rect = wxGetWindowRect(GetHwnd());
+ // if SetSize() had been called at wx level but not realized at Windows
+ // level yet (i.e. EndDeferWindowPos() not called), we still should return
+ // the new and not the old position to the other wx code
+ if ( m_pendingSize != wxDefaultSize )
+ {
+ if ( x )
+ *x = m_pendingSize.x;
+ if ( y )
+ *y = m_pendingSize.y;
+ }
+ else // use current size
+ {
+ RECT rect = wxGetWindowRect(GetHwnd());
- if ( x )
- *x = rect.right - rect.left;
- if ( y )
- *y = rect.bottom - rect.top;
+ if ( x )
+ *x = rect.right - rect.left;
+ if ( y )
+ *y = rect.bottom - rect.top;
+ }
}
// Get size *available for subwindows* i.e. excluding menu bar etc.
void wxWindowMSW::DoGetClientSize(int *x, int *y) const
{
+ // this is only for top level windows whose resizing is never deferred, so
+ // we can safely use the current size here
RECT rect = wxGetClientRect(GetHwnd());
if ( x )
void wxWindowMSW::DoGetPosition(int *x, int *y) const
{
- RECT rect = wxGetWindowRect(GetHwnd());
-
- POINT point;
- point.x = rect.left;
- point.y = rect.top;
+ wxWindow * const parent = GetParent();
- // we do the adjustments with respect to the parent only for the "real"
- // children, not for the dialogs/frames
- if ( !IsTopLevel() )
+ wxPoint pos;
+ if ( m_pendingPosition != wxDefaultPosition )
{
- HWND hParentWnd = 0;
- wxWindow *parent = GetParent();
- if ( parent )
- hParentWnd = GetWinHwnd(parent);
+ pos = m_pendingPosition;
+ }
+ else // use current position
+ {
+ RECT rect = wxGetWindowRect(GetHwnd());
- // Since we now have the absolute screen coords, if there's a
- // parent we must subtract its top left corner
- if ( hParentWnd )
- {
- ::ScreenToClient(hParentWnd, &point);
- }
+ POINT point;
+ point.x = rect.left;
+ point.y = rect.top;
- if ( parent )
+ // we do the adjustments with respect to the parent only for the "real"
+ // children, not for the dialogs/frames
+ if ( !IsTopLevel() )
{
- // We may be faking the client origin. So a window that's
- // really at (0, 30) may appear (to wxWin apps) to be at (0, 0).
- wxPoint pt(parent->GetClientAreaOrigin());
- point.x -= pt.x;
- point.y -= pt.y;
+ // Since we now have the absolute screen coords, if there's a
+ // parent we must subtract its top left corner
+ if ( parent )
+ {
+ ::ScreenToClient(GetHwndOf(parent), &point);
+ }
}
+
+ pos.x = point.x;
+ pos.y = point.y;
+ }
+
+ // we also must adjust by the client area offset: a control which is just
+ // under a toolbar could be at (0, 30) in Windows but at (0, 0) in wx
+ if ( parent && !IsTopLevel() )
+ {
+ const wxPoint pt(parent->GetClientAreaOrigin());
+ pos.x -= pt.x;
+ pos.y -= pt.y;
}
if ( x )
- *x = point.x;
+ *x = pos.x;
if ( y )
- *y = point.y;
+ *y = pos.y;
}
void wxWindowMSW::DoScreenToClient(int *x, int *y) const
*y = pt.y;
}
-void
+bool
wxWindowMSW::DoMoveSibling(WXHWND hwnd, int x, int y, int width, int height)
{
#if USE_DEFERRED_SIZING
parent->m_hDWP = (WXHANDLE)hdwp;
}
+ if ( hdwp )
+ {
+ // did deferred move, remember new coordinates of the window as they're
+ // different from what Windows would return for it
+ return true;
+ }
+
// otherwise (or if deferring failed) move the window in place immediately
- if ( !hdwp )
#endif // USE_DEFERRED_SIZING
+ if ( !::MoveWindow((HWND)hwnd, x, y, width, height, IsShown()) )
{
- if ( !::MoveWindow((HWND)hwnd, x, y, width, height, IsShown()) )
- {
- wxLogLastError(wxT("MoveWindow"));
- }
+ wxLogLastError(wxT("MoveWindow"));
}
+
+ // if USE_DEFERRED_SIZING, indicates that we didn't use deferred move,
+ // ignored otherwise
+ return false;
}
void wxWindowMSW::DoMoveWindow(int x, int y, int width, int height)
if (height < 0)
height = 0;
- DoMoveSibling(m_hWnd, x, y, width, height);
+ if ( DoMoveSibling(m_hWnd, x, y, width, height) )
+ {
+#if USE_DEFERRED_SIZING
+ m_pendingPosition = wxPoint(x, y);
+ m_pendingSize = wxSize(width, height);
+#endif // USE_DEFERRED_SIZING
+ }
}
// set the size of the window: if the dimensions are positive, just use them,
}
}
- m_pendingPosition = wxPoint(x, y);
- m_pendingSize = wxSize(width, height);
DoMoveWindow(x, y, width, height);
}