Thread: Save as boxes

  1. #1
    Registered User
    Join Date
    Mar 2002
    Posts
    112

    Save as boxes

    Hey, how do I make it so when a save as box open there will be a file already in the edit box? I've got the default path but I can't get the song name to show up.

    So to set the defualt path I've done:
    OPENFILENAME ofn;
    ofn.lpstrInitialDir = "c:\\Folder";

    but when I go
    ofn.lpstrFileTitle = "File";
    it doesn't work. I think this is the right member but I'm not sure. Can someone tell me what I'm doing wrong?

  2. #2
    Alipha
    Guest
    Looking at VC++ help-file, I gather you should use lpstrFile, not lpstrFileTitle. lpstrFileTitle
    is used to receive the file that they selected.

    "lpstrFile
    Points to a buffer that contains a filename used to initialize the File Name edit control. The first character of this buffer must be NULL if initialization is not necessary. When the GetOpenFileName or GetSaveFileName function returns, this buffer contains the drive designator, path, filename, and extension of the selected file.
    If the buffer is too small, the dialog box procedure copies the required size into this member.

    lpstrFileTitle
    Points to a buffer that receives the title of the selected file. For Windows versions 3.0 and 3.1, this buffer receives the filename and extension without path information. The application should use this string to display the file title. If this member is NULL, the function does not copy the file title. "

  3. #3
    Registered User
    Join Date
    Mar 2002
    Posts
    112
    Well when i use lpstrFile the program crashes and szFileName is what recieves the file the user selected.

  4. #4
    Registered User
    Join Date
    Dec 2001
    Posts
    421
    lpstrFile is a pointer, so when you write to it you'll crash your program.

    szFileName is what receives the file name... but how about you do what most programmers do and experiment with it. What i'm saying is that it is also a way for you to write data to the edit box in the save dialog.

    U.
    Quidquid latine dictum sit, altum sonatur.
    Whatever is said in Latin sounds profound.

  5. #5
    Registered User
    Join Date
    Mar 2002
    Posts
    112
    Thanks Uraldor.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Save vs Save As.... OPENFILENAME flags
    By csonx_p in forum Windows Programming
    Replies: 16
    Last Post: 06-01-2008, 02:42 PM
  2. save and save as functions
    By willc0de4food in forum Windows Programming
    Replies: 2
    Last Post: 06-29-2005, 02:49 AM
  3. save webpage? some save some not
    By kryptkat in forum Tech Board
    Replies: 3
    Last Post: 06-07-2005, 09:21 AM
  4. Request for comments
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-02-2004, 10:33 AM
  5. Problems with open and save boxes
    By pinkcheese in forum Windows Programming
    Replies: 3
    Last Post: 05-21-2002, 06:03 PM