2019-04-19 17:19:57 +08:00
|
|
|
#ifndef _TOOL_FILE_DIALOGEX_H_
|
|
|
|
#define _TOOL_FILE_DIALOGEX_H_
|
|
|
|
|
|
|
|
#include "modal_wnd_base.h"
|
|
|
|
|
2019-09-20 16:27:58 +08:00
|
|
|
#include <commdlg.h>
|
|
|
|
|
2019-09-22 11:08:20 +08:00
|
|
|
namespace nim_comp {
|
|
|
|
|
2019-04-19 17:19:57 +08:00
|
|
|
struct __POSITION {};
|
|
|
|
typedef __POSITION* POSITION;
|
|
|
|
|
|
|
|
class CFileDialogEx : public ModalWndBase
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef std::function<void(BOOL, std::wstring)> FileDialogCallback2;
|
|
|
|
|
|
|
|
enum FileDialogType
|
|
|
|
{
|
|
|
|
FDT_None,
|
|
|
|
FDT_OpenFile,
|
|
|
|
FDT_SaveFile
|
|
|
|
};
|
|
|
|
|
|
|
|
CFileDialogEx(void);
|
|
|
|
~CFileDialogEx(void);
|
|
|
|
|
|
|
|
public:
|
|
|
|
void SetDefExt(LPCTSTR lpszDefExt);
|
|
|
|
void SetFileName(LPCTSTR lpszFileName);
|
|
|
|
void SetFlags(DWORD dwFlags);
|
|
|
|
void SetFilter(LPCTSTR lpszFilter);
|
|
|
|
void SetFilter(std::map<LPCTSTR,LPCTSTR>& filters);
|
|
|
|
void SetMultiSel(BOOL bMultiSel = TRUE);
|
|
|
|
void SetParentWnd(HWND hParentWnd);
|
|
|
|
void SetTitle(LPCTSTR lpszTitle);
|
|
|
|
void SetFileNameBufferSize(DWORD dwSize);
|
|
|
|
|
|
|
|
void AyncShowOpenFileDlg(FileDialogCallback2 file_dialog_callback1);
|
|
|
|
void AyncShowSaveFileDlg(FileDialogCallback2 file_dialog_callback2);
|
|
|
|
virtual void SyncShowModal() override;
|
|
|
|
std::wstring GetPathName();
|
|
|
|
std::wstring GetFileName();
|
|
|
|
std::wstring GetFileExt();
|
|
|
|
std::wstring GetFileTitle();
|
|
|
|
std::wstring GetFolderPath();
|
|
|
|
|
|
|
|
POSITION GetStartPosition();
|
|
|
|
std::wstring GetNextPathName(POSITION& pos);
|
|
|
|
|
|
|
|
public:
|
|
|
|
OPENFILENAME m_stOFN;
|
|
|
|
|
|
|
|
private:
|
|
|
|
wchar_t m_szDefExt[64];
|
|
|
|
wchar_t m_szFilter[MAX_PATH];
|
|
|
|
wchar_t m_szFileName[MAX_PATH];
|
|
|
|
wchar_t * m_lpszFileName;
|
|
|
|
FileDialogType file_dialog_type_;
|
|
|
|
FileDialogCallback2 file_dialog_callback2_;
|
|
|
|
};
|
|
|
|
|
2019-09-22 11:08:20 +08:00
|
|
|
}
|
|
|
|
|
2019-04-19 17:19:57 +08:00
|
|
|
#endif //_TOOL_FILE_DIALOGEX_H_
|