Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- char *get_open_filename(char *filter, char *fname)
- {
- OPENFILENAMEW ofn;
- WCHAR szFile[MAX_PATH];
- HWND SitehWnd;
- SitehWnd = GetAncestor(GetActiveWindow(), GA_ROOTOWNER);
- string str_filter = string(filter).append("||");
- replace(str_filter.begin(), str_filter.end(), '|', '\0');
- string str_fname = fname;
- tstring tstr_filter = widen(str_filter);
- tstring tstr_fname = widen(str_fname);
- wchar_t *wstr_fname = const_cast<wchar_t *>(tstr_fname.c_str());
- ofn.lStructSize = sizeof(ofn);
- ofn.hwndOwner = SitehWnd;
- ofn.lpstrFile = wstr_fname;
- ofn.nMaxFile = sizeof(szFile);
- ofn.lpstrFilter = tstr_filter.c_str();
- ofn.nFilterIndex = 0;
- ofn.lpstrTitle = NULL;
- ofn.lpstrInitialDir = NULL;
- ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_LONGNAMES;
- if (GetOpenFileNameW(&ofn) != 0)
- {
- static string result;
- result = shorten(ofn.lpstrFile);
- return (char *)result.c_str();
- }
- return (char *)"";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement