Click here to Skip to main content
11,502,821 members (37,519 online)
Click here to Skip to main content

Implementing IShellBrowser to host IShellView

, 4 Jun 2001 CPOL 242.3K 3.7K 65
Rate this:
Please Sign up or sign in to vote.
Imitating the Windows Explorer
<!-- Article image -->

Sample Image - screen.gif

<!-- Main HTML starts here -->

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)

Share

About the Author

Leon Finker

United States United States
No Biography provided

Comments and Discussions

 
GeneralShowing only folders in tree Pin
Nethen30-Oct-10 23:49
memberNethen30-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 
GeneralrIt wasn't worked Pin
jalalymm15-Apr-07 1:56
memberjalalymm15-Apr-07 1:56 
QuestionHow to get thumbnail from windown Explorer? Pin
thanhthuyvn_vtajkhskjakjd16-Oct-06 22:13
memberthanhthuyvn_vtajkhskjakjd16-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 &quot;delete&quot; 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
sussorangerobin1-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 
GeneralRe: BrowseObject Pin
Member 370373711-Jul-11 19:19
memberMember 370373711-Jul-11 19:19 
GeneralRe: BrowseObject Pin
beyond57765-Apr-07 23:17
memberbeyond57765-Apr-07 23:17 
GeneralRe: using the same ishellview Pin
beyond57765-Apr-07 22:28
memberbeyond57765-Apr-07 22:28 
Generalexpanding tree view Pin
curious abc20-Sep-04 8:33
susscurious abc20-Sep-04 8:33 
GeneralGet Selection Pin
K-ballo10-Aug-04 5:40
memberK-ballo10-Aug-04 5:40 
GeneralRe: Get Selection Pin
Leon Finker10-Aug-04 14:25
memberLeon Finker10-Aug-04 14:25 
GeneralRe: Get Selection Pin
kmah209121-Apr-08 18:54
memberkmah209121-Apr-08 18:54 
QuestionHow to get a pointer of IShellBrowser in MFC application? Pin
Jeong2-Aug-04 23:43
memberJeong2-Aug-04 23:43 
AnswerRe: How to get a pointer of IShellBrowser in MFC application? Pin
Leon Finker3-Aug-04 1:52
memberLeon Finker3-Aug-04 1:52 
QuestionSorting? Pin
CabbageMonster16-Jul-04 11:45
memberCabbageMonster16-Jul-04 11:45 
QuestionC#? Pin
Frohmen27-May-04 1:35
memberFrohmen27-May-04 1:35 
Generalmerge menu and toolbar Pin
vicluck@bodaworld.com16-May-04 16:30
membervicluck@bodaworld.com16-May-04 16:30 
Generalmissing atlapp.h file Pin
Bkhowto8-Mar-04 18:41
memberBkhowto8-Mar-04 18:41 
GeneralRe: missing atlapp.h file Pin
vneumann9-Mar-04 0:13
membervneumann9-Mar-04 0:13 
GeneralHelp me to get Folder PIDL when Click in Explorer Pin
sumiselva16-Oct-03 9:07
membersumiselva16-Oct-03 9:07 
GeneralRe: Help me to get Folder PIDL when Click in Explorer Pin
Leon Finker22-Oct-03 6:26
memberLeon Finker22-Oct-03 6:26 
GeneralRe: Help me to get Folder PIDL when Click in Explorer Pin
CabbageMonster15-Jul-04 8:34
memberCabbageMonster15-Jul-04 8:34 
GeneralI want to know... Pin
raobo755-Sep-03 6:08
memberraobo755-Sep-03 6:08 
GeneralRe: I want to know... Pin
Leon Finker5-Sep-03 6:37
memberLeon Finker5-Sep-03 6:37 
GeneralRe: I want to know... Pin
raobo6-Sep-03 21:17
memberraobo6-Sep-03 21:17 
GeneralRe: I want to know... Pin
Leon Finker7-Sep-03 15:32
memberLeon Finker7-Sep-03 15:32 
GeneralRe: I want to know... Pin
raobo8-Sep-03 1:18
memberraobo8-Sep-03 1:18 
QuestionHow to notice folder changing? Pin
hiro017-Aug-03 7:52
memberhiro017-Aug-03 7:52 
AnswerRe: How to notice folder changing? Pin
Leon Finker17-Aug-03 8:27
memberLeon Finker17-Aug-03 8:27 
GeneralRe: How to notice folder changing? Pin
hiro018-Aug-03 5:08
memberhiro018-Aug-03 5:08 

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

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

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.150520.1 | Last Updated 5 Jun 2001
Article Copyright 2001 by Leon Finker
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid