From: Vadim Zeitlin Date: Tue, 23 Nov 2010 13:11:02 +0000 (+0000) Subject: Center task dialog-based wxProgressDialog on the parent window. X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/a4984245b6e01e4534d841ea12008793dd2a312c Center task dialog-based wxProgressDialog on the parent window. wxProgressDialog was created without the parent when using task dialogs so it was centred on screen and not on its parent as usual. Fix this by explicitly positioning it so that it's centered over the parent. Closes #12699. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@66244 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/docs/changes.txt b/docs/changes.txt index dac31aa9f4..5278f00faa 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -449,6 +449,7 @@ MSW: - Fix Cygwin 1.7 build (David Gangola). - Allow using wxDC::DrawText() with multiline texts. - Fix wxBitmapButton best size determination broken in 2.9.1. +- Center task dialog-based wxProgressDialog on the parent (John Roberts). diff --git a/src/msw/progdlg.cpp b/src/msw/progdlg.cpp index 4bceee31c7..cf03fd80f1 100644 --- a/src/msw/progdlg.cpp +++ b/src/msw/progdlg.cpp @@ -73,10 +73,12 @@ public: m_progressBarMarquee = false; m_skipped = false; m_notifications = 0; + m_parent = NULL; } wxCriticalSection m_cs; + wxWindow *m_parent; // Parent window only used to center us over it. HWND m_hwnd; // Task dialog handler long m_style; // wxProgressDialog style int m_value; @@ -632,6 +634,7 @@ bool wxProgressDialog::Show(bool show) m_sharedData->m_range = m_maximum; m_sharedData->m_state = Uncancelable; m_sharedData->m_style = GetPDStyle(); + m_sharedData->m_parent = GetTopParent(); if ( HasPDFlag(wxPD_CAN_ABORT) ) { @@ -821,6 +824,27 @@ wxProgressDialogTaskRunner::TaskDialogCallbackProc 0, MAKELPARAM(0, sharedData->m_range) ); + // We always create this task dialog with NULL parent because our + // parent in wx sense is a window created from a different thread + // and so can't be used as our real parent. However we still center + // this window on the parent one as the task dialogs do with their + // real parent usually. + if ( sharedData->m_parent ) + { + wxRect rect(wxRectFromRECT(wxGetWindowRect(hwnd))); + rect = rect.CentreIn(sharedData->m_parent->GetRect()); + ::SetWindowPos(hwnd, + NULL, + rect.x, + rect.y, + -1, + -1, + SWP_NOACTIVATE | + SWP_NOOWNERZORDER | + SWP_NOSIZE | + SWP_NOZORDER); + } + // If we can't be aborted, the "Close" button will only be enabled // when the progress ends (and not even then with wxPD_AUTO_HIDE). if ( !(sharedData->m_style & wxPD_CAN_ABORT) )