I have been looking hi and low on how to implement a save as... function for my tic tac toe game. I think I am almost there, but not quite. I have tried 2 approaches. I have used the old style OPENFILENAME and I have tried using the Common Item Dialog box. I seem to have more luck getting it to work better with the Common Item Dialog box.
However, I have 2 issues. First, sometimes when I am clicking around folders in the dialog box, then I go to the area where I enter the file name and press "save," it opens the last folder I had clicked on instead.
Second issue, how can I get the box below the file name entry to display the default extensions.
*apologies for the excessive tabs, it's in a case statement
// Create the FileOpenDialog object.
HRESULT hr = CoCreateInstance(CLSID_FileSaveDialog, NULL, CLSCTX_ALL,
// Show the Open dialog box.
hr = pFileOpen->SetDefaultExtension(L"dat");
hr = pFileOpen->Show(hWnd);
// Get the file name from the dialog box.
hr = pFileOpen->GetResult(&pItem);
hr = pItem->GetDisplayName(SIGDN_FILESYSPATH, &pszFilePath);
// Display the file name to the user.
LPWSTR path = pszFilePath;
wstring file = path;
string str(file.begin(), file.end());