diff --git a/include/wx/msw/filedlg.h b/include/wx/msw/filedlg.h index 86952b6c6b..d2ba87a54f 100644 --- a/include/wx/msw/filedlg.h +++ b/include/wx/msw/filedlg.h @@ -34,22 +34,9 @@ public: virtual void GetPaths(wxArrayString& paths) const wxOVERRIDE; virtual void GetFilenames(wxArrayString& files) const wxOVERRIDE; virtual bool SupportsExtraControl() const wxOVERRIDE { return true; } - void MSWOnInitDialogHook(WXHWND hwnd); virtual int ShowModal() wxOVERRIDE; - // wxMSW-specific implementation from now on - // ----------------------------------------- - - // called from the hook procedure on CDN_INITDONE reception - virtual void MSWOnInitDone(WXHWND hDlg); - - // called from the hook procedure on CDN_SELCHANGE. - void MSWOnSelChange(WXHWND hDlg); - - // called from the hook procedure on CDN_TYPECHANGE. - void MSWOnTypeChange(WXHWND hDlg, int nFilterIndex); - protected: virtual void DoMoveWindow(int x, int y, int width, int height) wxOVERRIDE; @@ -58,6 +45,21 @@ protected: virtual void DoGetPosition( int *x, int *y ) const wxOVERRIDE; private: + // Allow it to call MSWOnXXX() functions below. + friend class wxFileDialogMSWData; + + // called when the dialog is created + void MSWOnInitDialogHook(WXHWND hwnd); + + // called from the hook procedure on CDN_INITDONE reception + void MSWOnInitDone(WXHWND hDlg); + + // called from the hook procedure on CDN_SELCHANGE. + void MSWOnSelChange(WXHWND hDlg); + + // called from the hook procedure on CDN_TYPECHANGE. + void MSWOnTypeChange(WXHWND hDlg, int nFilterIndex); + // The real implementation of ShowModal() using traditional common dialog // functions. int ShowCommFileDialog(WXHWND owner); @@ -66,7 +68,7 @@ private: int ShowIFileDialog(WXHWND owner); // Get the data object, allocating it if necessary. - struct wxFileDialogMSWData& MSWData(); + wxFileDialogMSWData& MSWData(); wxArrayString m_fileNames; diff --git a/src/msw/filedlg.cpp b/src/msw/filedlg.cpp index d6e69363a1..28715b139d 100644 --- a/src/msw/filedlg.cpp +++ b/src/msw/filedlg.cpp @@ -149,14 +149,20 @@ void RestoreExceptionPolicy() // wxFileDialogMSWData: private data used by the dialog // ---------------------------------------------------------------------------- -struct wxFileDialogMSWData +class wxFileDialogMSWData { +public: wxFileDialogMSWData() { m_bMovedWindow = false; m_centreDir = 0; } + // Hook function used by the common dialogs: it's a member of this class + // just to allow it to call the private functions of wxFileDialog. + static UINT_PTR APIENTRY + HookFunction(HWND hDlg, UINT iMsg, WPARAM wParam, LPARAM lParam); + // remember if our SetPosition() or Centre() (which requires special // treatment) was called bool m_bMovedWindow; @@ -168,10 +174,10 @@ struct wxFileDialogMSWData // ---------------------------------------------------------------------------- UINT_PTR APIENTRY -wxFileDialogHookFunction(HWND hDlg, - UINT iMsg, - WPARAM WXUNUSED(wParam), - LPARAM lParam) +wxFileDialogMSWData::HookFunction(HWND hDlg, + UINT iMsg, + WPARAM WXUNUSED(wParam), + LPARAM lParam) { switch ( iMsg ) { @@ -590,7 +596,7 @@ int wxFileDialog::ShowCommFileDialog(WXHWND hWndParent) of.lpstrInitialDir = dir.c_str(); of.Flags = msw_flags; - of.lpfnHook = wxFileDialogHookFunction; + of.lpfnHook = wxFileDialogMSWData::HookFunction; of.lCustData = (LPARAM)this; wxArrayString wildDescriptions, wildFilters;