Use real number of children for reserving deferred sizing space;
fix apparent bug in Windows doing deferred positioning git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@33908 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -4164,15 +4164,34 @@ bool wxWindowMSW::HandleSize(int WXUNUSED(w), int WXUNUSED(h), WXUINT wParam)
|
|||||||
{
|
{
|
||||||
// when we resize this window, its children are probably going to be
|
// when we resize this window, its children are probably going to be
|
||||||
// repositioned as well, prepare to use DeferWindowPos() for them
|
// repositioned as well, prepare to use DeferWindowPos() for them
|
||||||
const int numChildren = GetChildren().GetCount();
|
#if USE_DEFERRED_SIZING
|
||||||
|
// when we resize this window, its children are probably going to be
|
||||||
|
// repositioned as well, prepare to use DeferWindowPos() for them
|
||||||
|
int numChildren = 0;
|
||||||
|
for ( HWND child = ::GetWindow(GetHwndOf(this), GW_CHILD);
|
||||||
|
child;
|
||||||
|
child = ::GetWindow(child, GW_HWNDNEXT) )
|
||||||
|
{
|
||||||
|
numChildren ++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Protect against valid m_hDWP being overwritten
|
||||||
|
bool useDefer = false;
|
||||||
|
|
||||||
if ( numChildren > 1 )
|
if ( numChildren > 1 )
|
||||||
{
|
{
|
||||||
m_hDWP = (WXHANDLE)::BeginDeferWindowPos(numChildren);
|
if (!m_hDWP)
|
||||||
if ( !m_hDWP )
|
{
|
||||||
{
|
m_hDWP = (WXHANDLE)::BeginDeferWindowPos(numChildren);
|
||||||
wxLogLastError(_T("BeginDeferWindowPos"));
|
if ( !m_hDWP )
|
||||||
|
{
|
||||||
|
wxLogLastError(_T("BeginDeferWindowPos"));
|
||||||
|
}
|
||||||
|
if (m_hDWP)
|
||||||
|
useDefer = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// update this window size
|
// update this window size
|
||||||
bool processed = false;
|
bool processed = false;
|
||||||
@@ -4205,8 +4224,9 @@ bool wxWindowMSW::HandleSize(int WXUNUSED(w), int WXUNUSED(h), WXUINT wParam)
|
|||||||
processed = GetEventHandler()->ProcessEvent(event);
|
processed = GetEventHandler()->ProcessEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if USE_DEFERRED_SIZING
|
||||||
// and finally change the positions of all child windows at once
|
// and finally change the positions of all child windows at once
|
||||||
if ( m_hDWP )
|
if ( useDefer && m_hDWP )
|
||||||
{
|
{
|
||||||
// reset m_hDWP to NULL so that child windows don't try to use our
|
// reset m_hDWP to NULL so that child windows don't try to use our
|
||||||
// m_hDWP after we call EndDeferWindowPos() on it (this shouldn't
|
// m_hDWP after we call EndDeferWindowPos() on it (this shouldn't
|
||||||
@@ -4214,13 +4234,34 @@ bool wxWindowMSW::HandleSize(int WXUNUSED(w), int WXUNUSED(h), WXUINT wParam)
|
|||||||
// may have depending on what the users EVT_SIZE handler does...)
|
// may have depending on what the users EVT_SIZE handler does...)
|
||||||
HDWP hDWP = (HDWP)m_hDWP;
|
HDWP hDWP = (HDWP)m_hDWP;
|
||||||
m_hDWP = NULL;
|
m_hDWP = NULL;
|
||||||
|
|
||||||
// do put all child controls in place at once
|
// do put all child controls in place at once
|
||||||
if ( !::EndDeferWindowPos(hDWP) )
|
if ( !::EndDeferWindowPos(hDWP) )
|
||||||
{
|
{
|
||||||
wxLogLastError(_T("EndDeferWindowPos"));
|
wxLogLastError(_T("EndDeferWindowPos"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Seems to be a bug in DeferWindowPos such that going from (a) to (b) to (a)
|
||||||
|
// doesn't work (omits last position/size). So check if there's a disparity,
|
||||||
|
// and correct.
|
||||||
|
for ( wxWindowList::compatibility_iterator node = GetChildren().GetFirst();
|
||||||
|
node;
|
||||||
|
node = node->GetNext() )
|
||||||
|
{
|
||||||
|
wxWindow *child = node->GetData();
|
||||||
|
wxExtraWindowData* extraData = (wxExtraWindowData*) child->m_windowReserved;
|
||||||
|
if (extraData && extraData->m_deferring)
|
||||||
|
{
|
||||||
|
wxPoint pos = child->GetPosition();
|
||||||
|
|
||||||
|
if (extraData->m_pos != pos)
|
||||||
|
child->Move(extraData->m_pos);
|
||||||
|
|
||||||
|
extraData->m_deferring = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return processed;
|
return processed;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user