#pragma once #include "shlobj.h" class CPathDialog; class CPathDialogSub : public CWnd { friend CPathDialog; public: CPathDialog* m_pdlg; protected: afx_msg void OnOK(); // OK button clicked afx_msg void OnChangeEditPath(); DECLARE_MESSAGE_MAP() }; ///////////////////////////////////////////////////////////////////////////// // CPathDialog dialog class CPathDialog { friend CPathDialogSub; // Construction public: CPathDialog(LPCTSTR pszCaption = NULL, LPCTSTR pszTitle = NULL, LPCTSTR pszInitialPath = NULL, CWnd* pParent = NULL); CString GetPathName(); virtual int DoModal(); static int Touch(LPCTSTR pszPath, BOOL bValidate = TRUE); static int MakeSurePathExists(LPCTSTR pszPath); static BOOL IsValidFileName(LPCTSTR pszFileName); static int ConcatPath(LPTSTR pszRoot, LPCTSTR pszMorePath); private: static int CALLBACK BrowseCallbackProc(HWND hwnd, UINT uMsg,LPARAM lParam, LPARAM pData); LPCTSTR m_pszCaption; LPCTSTR m_pszInitialPath; TCHAR m_szPathName[MAX_PATH]; BROWSEINFO m_bi; HWND m_hWnd; CWnd* m_pwndParent; BOOL m_bSuccess; CPathDialogSub m_dlg; };