Problems with open and save boxes

This is a discussion on Problems with open and save boxes within the Windows Programming forums, part of the Platform Specific Boards category; I'm having some problems with open and save boxes. Every time I open the open box and click open my ...

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

    Problems with open and save boxes

    I'm having some problems with open and save boxes. Every time I open the open box and click open my program goes all screwed up. After the first time a open box is opened I have problems with my directories.

    My code for the open box below opens a mp3
    Code:
    case ID_MUSIC_MUSICPLAYER:
    {
    	OPENFILENAME ofn;
    	char szFileName[MAX_PATH] = "";
    	ZeroMemory(&ofn, sizeof(ofn));
    	ofn.lStructSize = sizeof(ofn);
    	ofn.hwndOwner = NULL;
    	ofn.lpstrFilter = "MP3 Files (*.mp3)\0*.mp3\0All Files (*.*)\0*.*\0";
    	ofn.lpstrFile = szFileName;
    	ofn.nMaxFile = MAX_PATH;
    	ofn.Flags = OFN_FILEMUSTEXIST;
    	ofn.lpstrDefExt = "mp3";
    	ofn.lpstrInitialDir = "Downloaded Music";
    
    	if(GetOpenFileName(&ofn))
    	{
    		ShellExecute(hwnd, "open", ofn.lpstrFile, NULL, NULL, SW_MINIMIZE);
    	}
    }
    break;
    I also have some code that opens the directory with all the mp3s but after I've opened the mp3 with the code above it won't work anymore. The code to open the folder is below.
    Code:
    case ID_MUSIC_DOWNLOADEDMUSIC:
    	ShellExecute(hwnd, "explore", "Downloaded Music", NULL, NULL, SW_MAXIMIZE);
    break;
    I don't know why its doing this but I know it messes up the directories, because other stuff also doesn't work properly after using the mp3 launcher.

  2. #2
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,856
    Try

    Passing in a valid HWND. I have had problems with modality if I use non valid HWND.

    Set the init folder to "." or".//Downloaded Music"

    Set the file name to "*.mp3"

    Terminate the filter with two end of lines ie\0\0

    Make sure your mp3 have an 'open' command (right click on one and see if 'open' is a choice. If not use 'play' (?)

    You are suppling the file name but not the correct folder to the ShellExecute() as the mp3 comes from the "./downloaded music" folder.
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  3. #3
    Registered User
    Join Date
    Mar 2002
    Posts
    112
    hmm... I'll try all that stuff tommorow but I'm going to go to bed now. Thanks.

  4. #4
    Registered User
    Join Date
    Mar 2002
    Posts
    112
    Figured it out, never mind.
    Last edited by pinkcheese; 05-21-2002 at 07:09 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Open Save and Print (Windows Form)
    By MaGaIn in forum C# Programming
    Replies: 1
    Last Post: 02-24-2008, 06:05 AM
  2. save and save as functions
    By willc0de4food in forum Windows Programming
    Replies: 2
    Last Post: 06-29-2005, 02:49 AM
  3. Can't open save File!!
    By WackoWolf in forum C++ Programming
    Replies: 2
    Last Post: 11-14-2004, 09:39 AM
  4. Save as boxes
    By pinkcheese in forum Windows Programming
    Replies: 4
    Last Post: 04-10-2002, 11:16 PM
  5. Replies: 1
    Last Post: 11-23-2001, 09:01 AM

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