Hey, how do i make a save dialog (the one present in almost every program, that you choose where to save, ctrl+s in notepad )? I also want it to allow just .txt extension to be saved, thanks =]
Hey, how do i make a save dialog (the one present in almost every program, that you choose where to save, ctrl+s in notepad )? I also want it to allow just .txt extension to be saved, thanks =]
http://msdn.microsoft.com/library/de...vefilename.asp
http://msdn.microsoft.com/library/de...enfilename.asp
Look at lpstrFilter for the txt only.
Code:openfilename.lpstrFilter = "Text (*.TXT)\0";
Well, the function actually dont open any dialog box... here is my struct:
and here is the function being called:Code:OPENFILENAME b; b.Flags = OFN_CREATEPROMPT; b.hwndOwner = hwnd; b.lpstrDefExt = "txt"; b.lpstrFile = "teste.txt"; b.lpstrFileTitle = NULL; b.lpstrFilter = "*.txt"; b.lpstrInitialDir = NULL; b.lpstrTitle = NULL; b.lStructSize = 300000; b.nFilterIndex = 0; b.nMaxFile = 256;
Code:GetSaveFileName(&b);
??Code:b.lStructSize = 300000;
Code:b.lStructSize = sizeof(OPENFILENAME);??Code:b.lpstrFilter = "*.txt";
Code:b.lpstrFilter = "Text (*.TXT)\0";??Code:b.lpstrFile = "teste.txt";
Code:b.lpstrFile = buffer;Code:b.nMaxFile = MAX_PATHRead the documentation please.Code:TCHAR buf[MAX_PATH];
Thanks..
I read the documentation and corrected it, and now the dialog opens.
But where do i set the content of the file that will be saved? I dont got it, even reading the documentation
It will return the path to the file the user choose to save to in OPENFILENAME.lpstrFile and you can use that to open a file (createfile, fopen, ofstream), and then write whatever content you have to save in that file.
Thanks, everything its ok in that part of my program now =]