diff --git a/src/msw/filedlg.cpp b/src/msw/filedlg.cpp index 7327c7bdd7..15db452bae 100644 --- a/src/msw/filedlg.cpp +++ b/src/msw/filedlg.cpp @@ -172,22 +172,26 @@ wxFileDialogHookFunction(HWND hDlg, case WM_NOTIFY: { - OFNOTIFY* const - pNotifyCode = reinterpret_cast(lParam); - wxFileDialog* const - dialog = reinterpret_cast( - pNotifyCode->lpOFN->lCustData - ); - - switch ( pNotifyCode->hdr.code ) + NMHDR* const pNM = reinterpret_cast(lParam); + if ( pNM->code >= CDN_FIRST && pNM->code < CDN_LAST ) { - case CDN_INITDONE: - dialog->MSWOnInitDone((WXHWND)hDlg); - break; + OFNOTIFY* const + pNotifyCode = reinterpret_cast(lParam); + wxFileDialog* const + dialog = reinterpret_cast( + pNotifyCode->lpOFN->lCustData + ); - case CDN_SELCHANGE: - dialog->MSWOnSelChange((WXHWND)hDlg); - break; + switch ( pNotifyCode->hdr.code ) + { + case CDN_INITDONE: + dialog->MSWOnInitDone((WXHWND)hDlg); + break; + + case CDN_SELCHANGE: + dialog->MSWOnSelChange((WXHWND)hDlg); + break; + } } } break;