core/vgui/impl/mfc/vgui_dir_dialog.h
Go to the documentation of this file.
00001 #ifndef vgui_dir_dialog_h_
00002 #define vgui_dir_dialog_h_
00003 //:
00004 // \file
00005 // \brief  creates a directory browsing dialog, it allows to choose both directories and files
00006 // \author Gamze Tunali, LEMS, Brown University
00007 // \date   16 Nov 2007
00008 
00009 #if _MSC_VER >= 1000
00010 #pragma once
00011 #endif // _MSC_VER >= 1000
00012 
00013 // CDlgWnd - intercepts messages from child controls
00014 class CDlgWnd : public CWnd
00015 {
00016  public:
00017   void CheckDir(const CString &ss);   // Display directory contents
00018 
00019  protected:
00020   afx_msg void OnOpen();              // Open button clicked
00021 
00022   DECLARE_MESSAGE_MAP()
00023 };
00024 
00025 // CDirEdit - edit control class
00026 class CDirEdit : public CEdit
00027 {
00028  protected:
00029   afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
00030   afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
00031   afx_msg UINT OnGetDlgCode();
00032 
00033   DECLARE_MESSAGE_MAP()
00034 };
00035 
00036 // vgui_dir_dialog - directory selection dialog
00037 class vgui_dir_dialog : public CFileDialog
00038 {
00039  public:
00040   vgui_dir_dialog(LPCTSTR initial = NULL,
00041                   LPCTSTR filter = NULL, CWnd* pParentWnd = NULL);
00042 
00043   CString GetPath() { return m_strPath; }
00044 
00045   // Overriden members of CFileDialog
00046   virtual void OnInitDone();
00047   virtual void OnFolderChange();
00048 
00049   // Disallow selection of files (since we're only selecting directories)
00050   virtual BOOL OnFileNameOK(); // { return TRUE; }
00051  private:
00052   CString m_strPath;                  // Current directory
00053   CString m_strFilter;                // The current file filters string (used for string storage
00054                                       // for internal use of File Open dialog)
00055 
00056   CDlgWnd m_DlgWnd;                   // Subclassed dialog window (parent of vgui_dir_dialog window)
00057   CDirEdit m_Edit;                    // Edit control where you can type in a dir. name
00058   CButton m_Open;                     // "Open" button (replaces OK button)
00059 };
00060 
00061 #endif // vgui_dir_dialog_h_