Skip to content

Instantly share code, notes, and snippets.

@ZweiSteinSoft
Created November 27, 2012 10:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ZweiSteinSoft/b2c9f12311287feb0a0c to your computer and use it in GitHub Desktop.
Save ZweiSteinSoft/b2c9f12311287feb0a0c to your computer and use it in GitHub Desktop.
Pointer to ExtensionString
int32 ShowSaveDialog(ExtensionString title,
ExtensionString initialDirectory,
ExtensionString fileTypes,
CefRefPtr<ExtensionString>& selectedFile)
{
wchar_t szFile[MAX_PATH];
szFile[0] = 0;
// ofn.lpstrInitialDir needs Windows path on XP and not Unix path.
ConvertToNativePath(initialDirectory);
OPENFILENAME ofn;
ZeroMemory(&ofn, sizeof(ofn));
ofn.hwndOwner = GetActiveWindow();
ofn.lStructSize = sizeof(ofn);
ofn.lpstrFile = szFile;
ofn.nMaxFile = MAX_PATH;
// TODO (issue #65) - Use passed in file types. Note, when fileTypesStr is null, all files should be shown
/* findAndReplaceString( fileTypesStr, std::string(" "), std::string(";*."));
LPCWSTR allFilesFilter = L"All Files\0*.*\0\0";*/
ofn.lpstrFilter = L"All Files\0*.*\0Web Files\0*.js;*.css;*.htm;*.html\0\0";
ofn.lpstrInitialDir = initialDirectory.c_str();
ofn.Flags = OFN_PATHMUSTEXIST | OFN_OVERWRITEPROMPT | OFN_NOCHANGEDIR | OFN_EXPLORER;
selectedFile = L""; // "=" has red underline wave
if (GetSaveFileName(&ofn)) {
selectedFile = szFile;
}
return NO_ERROR;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment