📄 selectfolderdialog.h
字号:
/*
Original code by : Mihai Filimon
Modifications by S. Sridhar
1. Added a edit control where the user can type in the path
2. If the path typed in the edit ctrl does not exist then the
user will be propmted as to whether he/she wants the path
to be created
3. Setting the flag bShowFilesInDir to TRUE will result in all
the files in the current folder to be displayed in the dialog
4. If u don't want to display all the files then u can use the
file filter to display the file types u want to display
5. Calling API SetTitle with the desired title will set the Title
of the dialog. This API has to be invoked before DoModal is called
6. User can pass the Initial Folder to be displayed in the constructor
of CSelectFolder
Usage Examples
--------------
CSelectFolderDialog oSelectFolderDialog(FALSE, NULL,
OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
NULL, NULL);
CSelectFolderDialog oSelectFolderDialog(FALSE, "c:\\my documents",
OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
NULL, NULL);
CSelectFolderDialog oSelectFolderDialog(TRUE, "c:\\my documents",
OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
NULL, NULL);
CSelectFolderDialog oSelectFolderDialog(TRUE, "c:\\my documents",
OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
"Microsoft Word Documents (*.doc)|*.doc|Microsoft Excel Worksheets (*.xls)|*.xls|", NULL);
CSelectFolderDialog oSelectFolderDialog(TRUE, "c:\\my documents",
OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
"HTML Files (*.html, *.htm)|*.html;*.htm||", NULL);
*/
#if !defined(AFX_MYFD_H__F9CB9441_F91B_11D1_8610_0040055C08D9__INCLUDED_)
#define AFX_MYFD_H__F9CB9441_F91B_11D1_8610_0040055C08D9__INCLUDED_
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
//
/////////////////////////////////////////////////////////////////////////////
// CSelectFolderDialog dialog
class CSelectFolderDialog : public CFileDialog
{
DECLARE_DYNAMIC(CSelectFolderDialog)
public:
CSelectFolderDialog(BOOL bShowFilesInDir = FALSE,
LPCSTR lpcstrInitialDir = NULL,
DWORD dwFlags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
LPCTSTR lpszFilter = NULL, CWnd* pParentWnd = NULL);
~CSelectFolderDialog();
static WNDPROC m_wndProc;
virtual void OnInitDone();
virtual int DoModal();
void OnFolderChange();
void SetSelectedPath(LPCSTR lpcstrPath);
CString GetSelectedPath() const;
void SetTitle(CString cstrTitle);
protected:
//{{AFX_MSG(CSelectFolderDialog)
// NOTE - the ClassWizard will add and remove member functions here.
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
private:
BOOL m_bShowFilesInDir;
CString m_cstrPath;
CString m_cstrPath_Shadow;
CEdit *m_pEdit;
CString m_cstrTitle;
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_MYFD_H__F9CB9441_F91B_11D1_8610_0040055C08D9__INCLUDED_)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -