Click here to Skip to main content
15,394,023 members
Articles / Desktop Programming / WTL
Posted 4 Jun 2001


66 bookmarked

Implementing IShellBrowser to host IShellView

Rate me:
Please Sign up or sign in to vote.
4.84/5 (23 votes)
4 Jun 2001CPOL2 min read
Imitating the Windows Explorer

Sample Image - screen.gif


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



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


About the Author

Leon Finker
United States United States
No Biography provided

Comments and Discussions

GeneralShowing only folders in tree Pin
Member 2362230-Oct-10 23:49
MemberMember 2362230-Oct-10 23:49 
GeneralAwesome code! Pin
T800G10-Oct-09 1:43
MemberT800G10-Oct-09 1:43 
QuestionContext Menu Problem Pin
rImrose29-May-09 6:40
MemberrImrose29-May-09 6:40 
QuestionHow can I embed the whole Explorer window in my window Pin
Javed Akhtar Ansari3-Oct-08 0:55
MemberJaved Akhtar Ansari3-Oct-08 0:55 
Is it possible to embed the whole explorer window in a dialog or a window?

Javed A Ansari
Software Developer
Hyderabad, India

GeneralrIt wasn't worked Pin
jalalymm15-Apr-07 1:56
Memberjalalymm15-Apr-07 1:56 
QuestionHow to get thumbnail from windown Explorer? Pin
An Phung Nguyen16-Oct-06 22:13
MemberAn Phung Nguyen16-Oct-06 22:13 
Generalerror Pin
kiranin10-Sep-06 21:21
Memberkiranin10-Sep-06 21:21 
QuestionIs there any solution to implement this project on a dailog-based application? Pin
Aki Wang19-Jul-06 15:28
MemberAki Wang19-Jul-06 15:28 
GeneralNever ending dialog pops up Pin
R.D.H.2-May-06 6:24
MemberR.D.H.2-May-06 6:24 
QuestionHow to get the path for each icon in the Desktop folder Pin
giftsana22-Mar-06 15:27
Membergiftsana22-Mar-06 15:27 
AnswerRe: How to get the path for each icon in the Desktop folder Pin
giftsana27-Mar-06 19:18
Membergiftsana27-Mar-06 19:18 
GeneralSetting the path Pin
cowtongue215-Feb-06 17:06
Membercowtongue215-Feb-06 17:06 
Questionwhy cannot use "delete" key to delete file? Pin
tianzuo3-Nov-05 21:36
Membertianzuo3-Nov-05 21:36 
GeneralStatus bar messages and Multi Thread Pin
Guybrush19-Mar-05 11:55
MemberGuybrush19-Mar-05 11:55 
GeneralWM_DDE* messages seems are not sent Pin
alerma19-Oct-04 9:15
Memberalerma19-Oct-04 9:15 
GeneralRe: WM_DDE* messages seems are not sent Pin
RickyV19-Oct-04 14:09
MemberRickyV19-Oct-04 14:09 
GeneralRe: WM_DDE* messages seems are not sent Pin
alerma20-Oct-04 1:35
Memberalerma20-Oct-04 1:35 
GeneralRe: WM_DDE* messages seems are not sent Pin
RickyV20-Oct-04 14:12
MemberRickyV20-Oct-04 14:12 
GeneralRe: WM_DDE* messages seems are not sent Pin
Leon Finker20-Oct-04 14:40
MemberLeon Finker20-Oct-04 14:40 
GeneralDetecting cut/paste operations Pin
orangerobin1-Oct-04 2:41
Memberorangerobin1-Oct-04 2:41 
Generalusing the same ishellview Pin
RickyV20-Sep-04 21:27
MemberRickyV20-Sep-04 21:27 
GeneralRe: using the same ishellview Pin
Leon Finker21-Sep-04 13:55
MemberLeon Finker21-Sep-04 13:55 
GeneralRe: using the same ishellview Pin
RickyV21-Sep-04 15:03
MemberRickyV21-Sep-04 15:03 
GeneralBrowseObject Pin
quinthar13-Nov-04 22:21
Memberquinthar13-Nov-04 22:21 
GeneralRe: BrowseObject Pin
RickyV28-Nov-04 20:21
MemberRickyV28-Nov-04 20:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.