Save As Dialog Box

This is a discussion on Save As Dialog Box within the Windows Programming forums, part of the Platform Specific Boards category; Im wondering, is there an easy way to pop a save as dialoge box or do I have to make ...

  1. #1
    Codebot
    Join Date
    Jun 2004
    Location
    Toronto
    Posts
    195

    Save As Dialog Box

    Im wondering, is there an easy way to pop a save as dialoge box or do I have to make it myself??!
    Founder and avid member of the Internationsl Typo Associateion

  2. #2
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    GetSaveFileName will launch the 'save' Common Dialog box.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  3. #3
    Codebot
    Join Date
    Jun 2004
    Location
    Toronto
    Posts
    195
    Quote Originally Posted by Ken Fitlike
    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:

    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 dont get a save as window popping up at all. Any suggestions?
    Founder and avid member of the Internationsl Typo Associateion

  4. #4
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    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
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

  5. #5
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    and perhaps InitCommonCtrls() needs to be called?
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

  6. #6
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    >>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?
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  7. #7
    Codebot
    Join Date
    Jun 2004
    Location
    Toronto
    Posts
    195
    Quote Originally Posted by FillYourBrain
    and perhaps InitCommonCtrls() needs to be called?
    I added this line when my window starts up. and Also I changed the HWND of the struct so it looks like this:

    Code:
    FileName.hwndOwner         = WindowHwnd; //GetActiveWindow();
    WindowHwnd is what I get when I create the window.

    It Still Doesnt Work....
    Founder and avid member of the Internationsl Typo Associateion

  8. #8
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    You don't need InitCommonCtrls to use the common dialog boxes.

    Please post a minimal example that replicates the problem.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  9. #9
    Codebot
    Join Date
    Jun 2004
    Location
    Toronto
    Posts
    195
    Quote Originally Posted by Ken Fitlike
    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?
    Founder and avid member of the Internationsl Typo Associateion

  10. #10
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    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).
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  11. #11
    Codebot
    Join Date
    Jun 2004
    Location
    Toronto
    Posts
    195
    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 idebtification 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.
    Founder and avid member of the Internationsl Typo Associateion

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 9
    Last Post: 02-13-2008, 02:59 PM
  2. Parent of a BrowseForFolder dialog box
    By @nthony in forum Windows Programming
    Replies: 4
    Last Post: 01-08-2007, 02:54 PM
  3. New Theme
    By XSquared in forum A Brief History of Cprogramming.com
    Replies: 160
    Last Post: 04-01-2004, 08:00 PM
  4. 'Save' Dialog Box in console?
    By harryP in forum Windows Programming
    Replies: 2
    Last Post: 07-26-2003, 10:46 AM
  5. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 10:44 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21