15 ZeroMemory(&ofn,
sizeof(ofn));
16 ofn.lStructSize =
sizeof(ofn);
17 ofn.hwndOwner = parent.
handle();
18 ofn.lpstrFile = szFile;
21 ofn.lpstrFile[0] =
'\0';
22 ofn.nMaxFile =
sizeof(szFile);
23 ofn.lpstrFilter =
"All\0*.*\0Text\0*.TXT\0";
25 ofn.lpstrFileTitle = NULL;
26 ofn.nMaxFileTitle = 0;
27 ofn.lpstrInitialDir = NULL;
28 ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_ALLOWMULTISELECT | OFN_EXPLORER;
31 void initDir(
const std::string &dir)
33 ofn.lpstrInitialDir = dir.c_str();
35 void initFile(
const std::string &fname)
37 ofn.lpstrFileTitle = (LPSTR)fname.c_str();
51 ofn.lpstrFilter = fbuf;
57 ofn.lpstrDefExt = ext.c_str();
61 void title(
const std::string &fname)
63 ofn.lpstrTitle = fname.c_str();
72 if (GetOpenFileNameA(&ofn) == TRUE)
74 myfname = ofn.lpstrFile;
75 if (ofn.lpstrFile[ofn.nFileOffset - 1] == 0)
80 myfname += &ofn.lpstrFile[ofn.nFileOffset];
85 auto err = CommDlgExtendedError();
97 std::vector<std::string> ret;
98 if (GetOpenFileNameA(&ofn) == TRUE)
100 if (ofn.lpstrFile[ofn.nFileOffset - 1] != 0)
103 ret.push_back(ofn.lpstrFile);
107 std::string dir = ofn.lpstrFile;
108 int p = ofn.nFileOffset;
111 myfname = &ofn.lpstrFile[p];
114 ret.push_back(dir +
"\\" + myfname);
115 p += myfname.length() + 1;
127 if (GetSaveFileNameA(&ofn) == TRUE)
128 myfname = ofn.lpstrFile;
A popup window where used can browse folders and select a file.
Definition: filebox.h:9
std::string path() const
get filename entered by user
Definition: filebox.h:134
std::vector< std::string > openMulti()
prompt user for one or multiple files
Definition: filebox.h:95
void filter(const char *fbuf)
Set file filters.
Definition: filebox.h:48
std::string open()
prompt user for one file to open
Definition: filebox.h:70
void defaultExtension(const std::string &ext)
default extension for saved file, appended to whatever user enters
Definition: filebox.h:55
std::string save()
prompt user for folder and filename to save
Definition: filebox.h:125
The base class for all windex gui elements.
Definition: wex.h:824
HWND handle()
get window handle
Definition: wex.h:1655