Im wondering, is there an easy way to pop a save as dialoge box or do I have to make it myself??!
Printable View
Im wondering, is there an easy way to pop a save as dialoge box or do I have to make it myself??!
GetSaveFileName will launch the 'save' Common Dialog box.
I followed that link and looked at the examples, but im having a slight problem. My program seems to freeze at the line where its supposed to get the dialog box. Here is what I have code wise:Quote:
Originally Posted by Ken Fitlike
I dont get a save as window popping up at all. Any suggestions?Code:OPENFILENAME FileName;
bool SaveBox = false;
memset(&FileName, 0, sizeof(OPENFILENAME));
char FName[MAX_PATH] = "";
FileName.lStructSize = sizeof(OPENFILENAME);
FileName.hwndOwner = GetActiveWindow();
FileName.lpstrCustomFilter = NULL;
FileName.nFilterIndex = 0;
FileName.lpstrFile = FName;
FileName.nMaxFile = sizeof(FName);
FileName.lpstrFileTitle = NULL;
FileName.lpstrInitialDir = NULL;
FileName.lpstrTitle = NULL;
FileName.Flags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_PATHMUSTEXIST;
//FileName.lpstrDefExt = DefaultExt;
SaveBox = GetSaveFileName(&FileName); // IT HANGS HERE
I'm wondering about the GetActiveWindow() call. Could you just use the parent window handle directly? I can imagine a situation where the parent hwnd returned by GetActiveWindow might be a problem. Just guessing right now
and perhaps InitCommonCtrls() needs to be called?
>>I dont get a save as window popping up at all. Any suggestions?<<
Other than changing the type of your 'SaveBox' variable from bool to BOOL, the code looks fine to me. What compiler are you using?
I added this line when my window starts up. and Also I changed the HWND of the struct so it looks like this:Quote:
Originally Posted by FillYourBrain
WindowHwnd is what I get when I create the window.Code:FileName.hwndOwner = WindowHwnd; //GetActiveWindow();
It Still Doesnt Work.... :(
You don't need InitCommonCtrls to use the common dialog boxes.
Please post a minimal example that replicates the problem.
Oh i wish i could replicate the problem in a separate app. I wrote a little app that basically has the exact same code as the one posted in my first post, and it works completely fine. Do you suppose that maybe loading a certain library or something maybe be bugging out the dialogue code?Quote:
Originally Posted by Ken Fitlike
Well, given that when you write a simple example it works, it should be relatively straightforward to isolate what differences in the larger example are giving rise to the problem. You might find some of the diagnostic error code(s) returned by CommDlgExtendedError will further help in the identification of the problem(s).
Thats great that MS has these functions, but unfortunately my program hangs at GetSaveFileName() and therefore it doesnt even get to the next line after it, so therefore i cannot even call CommDlgExtendedError() afterwards.Quote:
Originally Posted by Ken Fitlike