The save is supposed to save the changes to the file if one is already open. If one is not, it will send the command message for SaveAs to prompt a dialog.
I have made a program like this before, and I have never needed any higher priviledge to save in Documents. It has always worked before.
My guess is that the fileName variable (LPSTR fileName = "") is not getting the value, but I am unsure. Because when I use tmp_file for the SaveAs, it seems to work. Also, I am using the same file writing function for Save as I am SaveAs. So the handles are exactly the same, so if it is invalid, the SaveAs should report the same error, but it does not.
So therefor the error cannot be in "SaveText()", it must be in the WM_COMMAND case for CTRL_MENU_FILE_SAVE.
And as to why that is I am still completely clueless.
Alright, I think I see where you're getting at.
So fileName = "", in the Window Procedure it checks if it is "" or not it sends a message for CTRL_MENU_SAVEAS, which calls the function SaveDlg expecting a LPSTR returned. Save Dialog returns the value put into the textbox via Save.File(); Which implementation is in dlgs.h
char* SaveFileDialog::File(void)
{
if(Opened)
{
if(Success)
return FileName;
else
{
if(ShowErrors == true)
{
MessageBox(_Parent, "An error occured or the operation was canceled!", "ERROR", MB_OK | MB_ICONERROR);
}
}
}
}
Assuming Opened & Success are true it returns FileName which ends up returned back in the Windows Procedure in tmp_file, it then calls SaveText with the tmp_file in hand. You're right this seems like a merry go round!
I guess next it's to see if Opened & Success are both evaluating to true. Try shoving a messagebox & a few elses in the SaveFileDialog::File() function, just to see, since if either of them aren't, it'll pretty much skip rest of the function without returning anything. (might be the problem)
To which I will take leave of this problem for the moment here, since I really need some sleep now

I would imagine someone else will be able to sort it since there are far better programmers than myself here. So good luck.