pierw kod:
#include <windows.h>
#include <iostream.h>
#include <commdlg.h>
#include <tchar.h>
using namespace std;
char *SaveFileDialog(HWND owner, DWORD maxFilePath) {
OPENFILENAME ofn; // common dialog box structure
TCHAR szFile[MAX_PATH]; // buffer for file name
// Initialize OPENFILENAME
ZeroMemory(&ofn, sizeof(ofn));
ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = owner;
ofn.lpstrFile = szFile;
ofn.lpstrFile[0] = '\0';
ofn.nMaxFile = sizeof(szFile);
ofn.lpstrFilter = _T("All Files\0*.*\0Text Files\0*.TXT\0");
ofn.nFilterIndex = 1;
ofn.lpstrFileTitle = NULL;
ofn.nMaxFileTitle = 0;
ofn.lpstrInitialDir = NULL;
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
// Display the Open dialog box
if (GetSaveFileName(&ofn) == TRUE)
{
return ofn.lpstrFile;
} else
{
return NULL;
}
}
int main(int argc, char* argv[])
{
char *data=SaveFileDialog(NULL,NULL);
if(data!=NULL)
{
cout << data << endl;
delete data;
}
else
cout << "NULL" << endl;
}
jak wyświetli sie okno to czy mozna w nazwie pliku ustawic na wejsciu proponowaną nazwe pilku zeby nie wpisywac recznie czy tez zaznaczac inny plik
