From 1de1c62872bf4fa080df2251d4b269dba5d6c541 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 25 May 2022 19:10:31 +0100 Subject: [PATCH] Pass the correct HWND to MSWOnInitDone() Instead of requiring the function itself to use GetParent(), call it in the hook function and pass the actual dialog HWND to MSWOnInitDone(). No real changes, just refactoring to prepare for further changes. --- src/msw/filedlg.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/msw/filedlg.cpp b/src/msw/filedlg.cpp index 4abd25ec1a..f7e45c4d41 100644 --- a/src/msw/filedlg.cpp +++ b/src/msw/filedlg.cpp @@ -319,7 +319,9 @@ wxFileDialogMSWData::HookFunction(HWND hDlg, switch ( pNM->code ) { case CDN_INITDONE: - dialog->MSWOnInitDone((WXHWND)hDlg); + // Note the dialog is the parent window: hDlg is a + // child of it when OFN_EXPLORER is used + dialog->MSWOnInitDone((WXHWND)::GetParent(hDlg)); // Call selection change handler so that update // handler will be called once with no selection. @@ -502,18 +504,14 @@ void wxFileDialog::MSWOnInitDone(WXHWND hDlg) return; } - // note the dialog is the parent window: hDlg is a child of it when - // OFN_EXPLORER is used - HWND hFileDlg = ::GetParent((HWND)hDlg); - // set HWND so that our DoMoveWindow() works correctly - TempHWNDSetter set(this, (WXHWND)hFileDlg); + TempHWNDSetter set(this, hDlg); if ( m_data->m_centreDir ) { // now we have the real dialog size, remember it RECT rect; - GetWindowRect(hFileDlg, &rect); + GetWindowRect(hDlg, &rect); gs_rectDialog = wxRectFromRECT(rect); // and position the window correctly: notice that we must use the base