Save Dialog

This is a discussion on Save Dialog within the Windows Programming forums, part of the Platform Specific Boards category; Hey, how do i make a save dialog (the one present in almost every program, that you choose where to ...

  1. #1
    Registered User
    Join Date
    Sep 2006
    Posts
    57

    Save Dialog

    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 =]

  2. #2
    Registered User Tonto's Avatar
    Join Date
    Jun 2005
    Location
    New York
    Posts
    1,465
    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";

    ╔╗╔╦══╦╗╔╦══╦╗
    ║╚╝║╔╗║╚╝║╔╗║║
    ║╔╗║╠╣║╔╗║╠╣╠╣
    ╚╝╚╩╝╚╩╝╚╩╝╚╩╝

    codez http://code.google.com/p/zxcvbn/

  3. #3
    Registered User
    Join Date
    Sep 2006
    Posts
    57
    Well, the function actually dont open any dialog box... here is my struct:
    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;
    and here is the function being called:
    Code:
    					GetSaveFileName(&b);

  4. #4
    Registered User Tonto's Avatar
    Join Date
    Jun 2005
    Location
    New York
    Posts
    1,465
    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_PATH
    Code:
    TCHAR buf[MAX_PATH];
    Read the documentation please.

    ╔╗╔╦══╦╗╔╦══╦╗
    ║╚╝║╔╗║╚╝║╔╗║║
    ║╔╗║╠╣║╔╗║╠╣╠╣
    ╚╝╚╩╝╚╩╝╚╩╝╚╩╝

    codez http://code.google.com/p/zxcvbn/

  5. #5
    Registered User
    Join Date
    Sep 2006
    Posts
    57
    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

  6. #6
    Registered User Tonto's Avatar
    Join Date
    Jun 2005
    Location
    New York
    Posts
    1,465
    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.

    ╔╗╔╦══╦╗╔╦══╦╗
    ║╚╝║╔╗║╚╝║╔╗║║
    ║╔╗║╠╣║╔╗║╠╣╠╣
    ╚╝╚╩╝╚╩╝╚╩╝╚╩╝

    codez http://code.google.com/p/zxcvbn/

  7. #7
    Registered User
    Join Date
    Sep 2006
    Posts
    57
    Thanks, everything its ok in that part of my program now =]

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. make Child Dialog not Popup?
    By Zeusbwr in forum Windows Programming
    Replies: 5
    Last Post: 04-08-2005, 02:42 PM
  2. MFC Save As dialog
    By Micko in forum Windows Programming
    Replies: 0
    Last Post: 08-23-2004, 02:02 PM
  3. Using standard C fscanf function with win32 save dialog
    By korbitz in forum Windows Programming
    Replies: 1
    Last Post: 04-08-2004, 03:31 PM
  4. Save As Dialog not saving correctly
    By jkw2068 in forum Windows Programming
    Replies: 10
    Last Post: 08-12-2003, 01:39 PM
  5. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 09:44 AM

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