Here you go:
// save file dialog
string SaveFileDialog( HWND hwnd, LPSTR filter, LPSTR dir, LPSTR title )
{
// save current directory
char * cdir = dbGetDir();
string file;
char szFile[MAX_PATH];
OPENFILENAME ofn;
ZeroMemory ( &ofn, sizeof ( ofn ) );
ofn.lStructSize = sizeof ( ofn );
ofn.hwndOwner = hwnd;
ofn.lpstrFile = szFile;
ofn.lpstrFile[0] = '\0';
ofn.nMaxFile = sizeof ( szFile );
ofn.lpstrFilter = filter;
ofn.nFilterIndex = 1;
ofn.lpstrFileTitle = title;
ofn.nMaxFileTitle = 0;
ofn.lpstrInitialDir = dir;
ofn.Flags = OFN_OVERWRITEPROMPT;
if ( GetSaveFileName ( &ofn ) )
file = ofn.lpstrFile;
// reset directory
dbSetDir( cdir );
// return file
return file;
}
Usage example:
string file_name = SaveFileDialog( NULL, "Text File (*.txt)\0*.TXT\0", "", "File.txt" );
Now the plot thickens, the fps decreases, and the awesomeness goes through the roof.