Browse
-
How can i let the users browse a DIRECTORY ( not a file! ) (let's say when cliking on the BROWSE button)??? it would be a great help
If you are looking for a DirOpenDialog, use this function: SHBrowseForFolder( BROWSEINFO *mPtrBInfo ); Look in MSDN for detail info about the BROWSEINFO structure. You can use this for Printer, Network resource, etc... BOOL SelectFolder( CString& nFolderName, LPCTSTR nTitulo, UINT nFlags ) { BOOL bRet; char pszPath[MAX_PATH]; BROWSEINFO mPtrBInfo; mPtrBInfo.hwndOwner = NULL; // HWND mPtrBInfo.pidlRoot = NULL; // LPCITEMIDLIST mPtrBInfo.pszDisplayName = pszPath; // LPTSTR mPtrBInfo.lpszTitle = nTitulo; // LPCTSTR mPtrBInfo.ulFlags = nFlags | BIF_RETURNONLYFSDIRS; mPtrBInfo.lpfn = NULL; // BFFCALLBACK mPtrBInfo.lParam = 0L; // LPARAM mPtrBInfo.iImage = 0; // int if ( OleInitialize( NULL ) != S_OK ) AfxMessageBox( "Error inicializando OLE" ); ITEMIDLIST *mPtrIList = SHBrowseForFolder( &mPtrBInfo ); bRet = SHGetPathFromIDList( mPtrIList, pszPath ); OleUninitialize(); if ( bRet ) nFolderName = pszPath; return bRet; }