From ffe84cfb994a5ff04977998cf30254a2bcbad91f Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 29 Oct 2017 19:45:35 +0100 Subject: [PATCH] Factor out wxProgressDialog::GetTaskDialogRect() No real changes, just prepare for implementing DoGetSize() in this class by extracting the common part between the existing DoGetPosition() and it in a new function. --- include/wx/msw/progdlg.h | 4 ++++ src/msw/progdlg.cpp | 24 ++++++++++++++++++------ 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/include/wx/msw/progdlg.h b/include/wx/msw/progdlg.h index c54d96c689..08495c8e46 100644 --- a/include/wx/msw/progdlg.h +++ b/include/wx/msw/progdlg.h @@ -68,6 +68,10 @@ private: // been entered. void UpdateExpandedInformation(int value); + // Get the task dialog geometry when using the native dialog. + wxRect GetTaskDialogRect() const; + + wxProgressDialogTaskRunner *m_taskDialogRunner; wxProgressDialogSharedData *m_sharedData; diff --git a/src/msw/progdlg.cpp b/src/msw/progdlg.cpp index 03fa9d7262..feba07ea9b 100644 --- a/src/msw/progdlg.cpp +++ b/src/msw/progdlg.cpp @@ -803,17 +803,29 @@ void wxProgressDialog::DoMoveWindow(int x, int y, int width, int height) wxGenericProgressDialog::DoMoveWindow(x, y, width, height); } +wxRect wxProgressDialog::GetTaskDialogRect() const +{ + wxRect r; + +#ifdef wxHAS_MSW_TASKDIALOG + if ( m_sharedData ) + { + wxCriticalSectionLocker locker(m_sharedData->m_cs); + r = wxRectFromRECT(wxGetWindowRect(m_sharedData->m_hwnd)); + } +#else // !wxHAS_MSW_TASKDIALOG + wxFAIL_MSG( "unreachable" ); +#endif // wxHAS_MSW_TASKDIALOG/!wxHAS_MSW_TASKDIALOG + + return r; +} + void wxProgressDialog::DoGetPosition(int *x, int *y) const { #ifdef wxHAS_MSW_TASKDIALOG if ( HasNativeTaskDialog() ) { - wxRect r; - if ( m_sharedData ) - { - wxCriticalSectionLocker locker(m_sharedData->m_cs); - r = wxRectFromRECT(wxGetWindowRect(m_sharedData->m_hwnd)); - } + const wxRect r = GetTaskDialogRect(); if (x) *x = r.x; if (y)