file browser window in a .cpp file

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Apr 2008
Posts: 2
Reputation: opendep is an unknown quantity at this point 
Solved Threads: 0
opendep opendep is offline Offline
Newbie Poster

file browser window in a .cpp file

 
0
  #1
Apr 22nd, 2008
Hi,
I am using visual studio 8 to create an application. I need to incorporate file browser window in a .cpp file. The code i have only browses the folders and sub folders but does not display the individual files. Can anyone help me with this..? Any help would be greatly appreciated. Thanks a lot.

my code is

  1.  
  2. void BrowseFolder( void )
  3. {
  4. TCHAR path[MAX_PATH];
  5. BROWSEINFO bi = { 0 };
  6. bi.lpszTitle = (LPCWSTR)("All Folders Automatically Recursed.");
  7. LPITEMIDLIST pidl = SHBrowseForFolder ( &bi );
  8.  
  9. if ( pidl != 0 )
  10. {
  11. SHGetPathFromIDList ( pidl, (LPWSTR)path );
  12. SetCurrentDirectory ( (LPCWSTR)path );
  13. SearchFolder( path );
  14. IMalloc * imalloc = 0;
  15. if ( SUCCEEDED( SHGetMalloc ( &imalloc )) )
  16. {
  17. imalloc->Free ( pidl );
  18. imalloc->Release ( );
  19. }
  20. }
  21. }
  22.  
  23.  
  24. void SearchFolder( TCHAR * path )
  25. {
  26. WIN32_FIND_DATA FindFileData;
  27. HWND m_listbox_hwnd;
  28. HANDLE hFind;
  29. TCHAR filename[ MAX_PATH + 256 ];
  30. TCHAR pathbak[ MAX_PATH ];
  31.  
  32. strcpy( (char *)pathbak, (char *)path );
  33.  
  34. hFind = FindFirstFile ( (LPCWSTR)"*.*", &FindFileData );
  35. do
  36. {
  37. if ( hFind != INVALID_HANDLE_VALUE )
  38. {
  39. if ( ! ( strcmp( (char *)FindFileData.cFileName, "." ) ) ||
  40. ! ( strcmp( (char *)FindFileData.cFileName, ".." ) ) )
  41. {
  42. continue;
  43. }
  44. strcpy( (char *)path, (char *)pathbak );
  45. sprintf((char *) path, "%s\\%s", (char *)path, FindFileData.cFileName );
  46. if ( ( SetCurrentDirectory( path ) ) )
  47. {
  48. SearchFolder( path );
  49. }
  50. SendMessage( m_listbox_hwnd, LB_ADDSTRING, 0, path );
  51. }
  52. }
  53. while ( FindNextFile ( hFind, &FindFileData )
  54. && hFind != INVALID_HANDLE_VALUE );
  55. FindClose ( hFind );
  56. }
Last edited by Ancient Dragon; Apr 22nd, 2008 at 9:40 am. Reason: replaced icode tags with code tags
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 979
Reputation: mitrmkar is just really nice mitrmkar is just really nice mitrmkar is just really nice mitrmkar is just really nice mitrmkar is just really nice 
Solved Threads: 209
mitrmkar mitrmkar is offline Offline
Posting Shark

Re: file browser window in a .cpp file

 
0
  #2
Apr 22nd, 2008
Use the BIF_BROWSEINCLUDEFILES flag in the BROWSEINFO's ulFlags member.
http://msdn2.microsoft.com/en-us/lib...05(VS.85).aspx
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 2
Reputation: opendep is an unknown quantity at this point 
Solved Threads: 0
opendep opendep is offline Offline
Newbie Poster

Re: file browser window in a .cpp file

 
0
  #3
Apr 22nd, 2008
hi,
Its working.. Thanks a lot..

regards,
AM
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C++ Forum
Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC