Thread: GetOpenFileName common dialog - What about the folder select dialog?

  1. #1
    Registered User
    Join Date
    Jun 2008
    Posts
    161

    GetOpenFileName common dialog - What about the folder select dialog?

    Is there an easy method for bringing up the standard dialog to pick a directory (tree view) that most programs, including explorer, use? I like the simplicity of GetOpenFileName and the OPENFILENAME struct.

  2. #2
    Registered User
    Join Date
    Dec 2007
    Posts
    214
    Look at SHBrowseForFolder function. Although thats doesn't have the same look as the standard file dialog, so maybe not what you want.

  3. #3
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    My function:
    Code:
    	Error BrowseForFolder(CWnd* pParentWnd, const Strings::CStringEx& strTitle, bool /*bLastFolder*/, Strings::CStringEx& strFolder, bool bEdit)
    	{
    		BROWSEINFO bi;
    		TCHAR Buffer[MAX_PATH];
    		ZeroMemory(Buffer, MAX_PATH);
    		ZeroMemory(&bi, sizeof(bi));
    		bi.hwndOwner = pParentWnd ? pParentWnd->m_hWnd : NULL;
    		bi.pszDisplayName = Buffer;
    		bi.lpszTitle = strTitle.get();
    		bi.ulFlags = bEdit ? BIF_EDITBOX : 0 | BIF_NEWDIALOGSTYLE | BIF_RETURNONLYFSDIRS | BIF_SHAREABLE;
    		LPCITEMIDLIST pFolder = SHBrowseForFolder(&bi);
    		if (pFolder == NULL) return ERROR_CANCEL;
    		if (! SHGetPathFromIDList(pFolder, Buffer) ) return ERROR_BAD_PATH;
    		strFolder = Buffer;
    		return (Error)ERROR_SUCCESS;
    	}
    Hope it makes sense and helps you.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  4. #4
    Registered User
    Join Date
    Jun 2008
    Posts
    161
    Thanks

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Common Dialog boxes GetOpenFileName()
    By A10 in forum Windows Programming
    Replies: 3
    Last Post: 09-02-2008, 08:56 PM
  2. brace-enclosed error
    By jdc18 in forum C++ Programming
    Replies: 53
    Last Post: 05-03-2007, 05:49 PM
  3. Folder selection menu using Common Dialog Box?
    By Devil Panther in forum Windows Programming
    Replies: 6
    Last Post: 04-29-2007, 01:09 PM
  4. GetOpenFileName() dialog box
    By bennyandthejets in forum Windows Programming
    Replies: 2
    Last Post: 12-20-2002, 03:15 PM
  5. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 09:44 AM