Click here to Skip to main content
6,629,377 members and growing! (22,982 online)
Email Password   helpLost your password?
Desktop Development » Shell and IE programming » General     Intermediate License: The Code Project Open License (CPOL)

Implementing IShellBrowser to host IShellView

By Leon Finker

Imitating the Windows Explorer
VC6Win2K, Visual Studio, ATL, WTL, Dev
Posted:4 Jun 2001
Views:167,290
Bookmarked:44 times
Announcements
Loading...
 
Search    
Advanced Search
Add to IE Search
printPrint   add Share
      Discuss Discuss   Broken Article?Report  
21 votes for this article.
Popularity: 6.14 Rating: 4.65 out of 5

1

2
1 vote, 5.6%
3
4 votes, 22.2%
4
13 votes, 72.2%
5

Sample Image - screen.gif

Introduction

I wondered how I can simulate the Windows explorer listview of files. Here is what I found. It might be useful to someone. If you create a simple listview control and populate it with files/folders, you'll notice that you can't:

  • Easily detect changes to files (rename, delete, copy/move...etc) while user is viewing the list
  • Send To menu is not populated if you try to use the shell's menu for your items
  • There doesn't seem to be a way of getting the column names used in shellview (filename, size, owner, times, and many others)

I found that Windows explorer and File Open dialog expose IShellBrowser, which is used by IShellFolder/IShellView to create the listview of files. So, I created a simple app with WTL. Implemented basic IShellBrowser methods and exposed it to IShellView through IShellFolder::CreateViewObject. Finally, to create the listview I called IShellView::CreateViewWindow. I didn't try to merge the menus.
Things I couldn't get to work:

  • Toolbar buttons (they were added to my toolbar, but bitmaps were messed up). They do function however.
  • The most important one for me was that I couldn't easily detect when user wanted to open/explore/search the selected folder so I could sync the file tree.

The IShellBrowser::BrowseObject was never even called, so I didn't implement it, but it should be implemented because most NSEs use this method. I did find that the shellview sends WM_DDE* messages and if you respond properly you'll get the info about the action user taken. The needed messages are WM_DDE_INITIATE, WM_DDE_EXECUTE, WM_DDE_TERMINATE. WM_DDE_EXECUTE will give you string such as
"[ViewFolder("C:\Documents and Settings\leon\Desktop\billing", :428:780, 1)]". I have no idea what the 428:780 stand for. But action would be ViewFolder/ExploreFolder/FindFolder. It would be nice if Microsoft documented this stuff then we could use it. But as things stand now they even say in the MSDN:

"You do not implement this interface directly. IShellBrowser is implemented by Windows Explorer and by the Windows File Open common dialog box."

But then why did they tell us about WM_GETISHELLBROWSER? Anyway, maybe it would be useful to someone, so here it is.

Some useful points:

  • To get drag drop functioning in shellview, call OleInitialize/OleUninitialize
  • Make sure you respond properly to WM_GETISHELLBROWSER or CreateView might crash
  • Details listview seems to work only with FVM_DETAILS and FWF_SNAPTOGRID combination
  • ICommDlgBrowser can be supported to have a simple listview like in common file dialog boxes (without webview)
  • Don't name your executable as explorer.exe or unpleasant things will happen

Useful links

Disclaimer: THIS CODE AND INFORMATION IS PROVIDED 'AS IS' WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Leon Finker


Member

Location: United States United States

Other popular Shell and IE programming articles:

Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 25 of 69 (Total in Forum: 69) (Refresh)FirstPrevNext
GeneralAwesome code! PinmemberT800G2:43 10 Oct '09  
QuestionContext Menu Problem PinmemberrImrose7:40 29 May '09  
QuestionHow can I embed the whole Explorer window in my window PinmemberJaved Akhtar Ansari1:55 3 Oct '08  
GeneralrIt wasn't worked Pinmemberjalalymm2:56 15 Apr '07  
GeneralHow to get thumbnail from windown Explorer? Pinmemberthanhthuyvn_vtajkhskjakjd23:13 16 Oct '06  
Generalerror Pinmemberkiranin22:21 10 Sep '06  
GeneralIs there any solution to implement this project on a dailog-based application? PinmemberAki Wang16:28 19 Jul '06  
GeneralNever ending dialog pops up PinmemberR.D.H.7:24 2 May '06  
GeneralHow to get the path for each icon in the Desktop folder Pinmembergiftsana16:27 22 Mar '06  
GeneralRe: How to get the path for each icon in the Desktop folder Pinmembergiftsana20:18 27 Mar '06  
GeneralSetting the path Pinmembercowtongue218:06 15 Feb '06  
Questionwhy cannot use "delete" key to delete file? Pinmembertianzuo22:36 3 Nov '05  
GeneralStatus bar messages and Multi Thread PinmemberGuybrush12:55 19 Mar '05  
GeneralWM_DDE* messages seems are not sent Pinmemberalerma10:15 19 Oct '04  
GeneralRe: WM_DDE* messages seems are not sent PinmemberRickyV15:09 19 Oct '04  
GeneralRe: WM_DDE* messages seems are not sent Pinmemberalerma2:35 20 Oct '04  
GeneralRe: WM_DDE* messages seems are not sent PinmemberRickyV15:12 20 Oct '04  
GeneralRe: WM_DDE* messages seems are not sent PinmemberLeon Finker15:40 20 Oct '04  
GeneralDetecting cut/paste operations Pinsussorangerobin3:41 1 Oct '04  
Generalusing the same ishellview PinmemberRickyV22:27 20 Sep '04  
GeneralRe: using the same ishellview PinmemberLeon Finker14:55 21 Sep '04  
GeneralRe: using the same ishellview PinmemberRickyV16:03 21 Sep '04  
GeneralBrowseObject Pinmemberquinthar23:21 13 Nov '04  
GeneralRe: BrowseObject PinmemberRickyV21:21 28 Nov '04  
GeneralRe: BrowseObject Pinmemberbeyond57760:17 6 Apr '07  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 4 Jun 2001
Editor: Chris Maunder
Copyright 2001 by Leon Finker
Everything else Copyright © CodeProject, 1999-2009
Web18 | Advertise on the Code Project