2

We need to host explorer-like browser window in our application. We cann't use new IExplorerBrowser because of need to keep compatibility with Windows XP.

The main problem is we need to show items in "Large Icons" mode by default. Unfortunately, calling IShellVIew.CreateViewWindow() with FOLDERSETTINGS.viewMode = 0x1 /* LargeIcon */ doesn't change view mode to desired. But I can do this manually by context menu in the window.

So we need to set "Large Icons" view mode. I didn't found any way to programmatically get context menu for the view itself.

Then, I've found that IShellView2 seems has needed way to go - IShellView2.CreateViewWindow2() that receives view mode as GUID rather than predefined const. But cann't get access to the interface!

IShellFolder.CreateViewObject(hwndOwner, typeof(IShellView).GUID) returns correct instance. But when I try IShellFolder.CreateViewObject(hwndOwner, typeof(IShellView2).GUID) I've got exception "Specified cast is not valid".

How can I obtain object for IShellView2 interface???

irium
  • 691
  • 8
  • 14

1 Answers1

4

Call the QueryInterface method on the IShellView object to ask it for IID_IShellView2.

Jonathan Potter
  • 36,172
  • 4
  • 64
  • 79
  • Yes, I've got it. It can be done just by simple cast in C#: `var shellView2 = (IShellView2) shellView;` But main problem is that object doesn't implement CreateViewWindow2() :((( I donn't know : maybe I should open new question? Or change this one? – irium Sep 21 '12 at 21:45
  • If the object doesn't implement the interface then you won't be able to use the interface :) – Jonathan Potter Sep 21 '12 at 22:06
  • As a kludge, you could use Spy++ to watch what `WM_COMMAND` id is generated by selecting Large Icons from the context menu, and then just post the same message yourself. – Jonathan Potter Sep 21 '12 at 22:07
  • @JonathanPotter: I'm getting mad with showing the Windows Context Menu Dialog, can you help me here? I would really appreciate. https://stackoverflow.com/questions/64928951/c-sharp-how-to-open-the-windows-shellex-inside-my-app – Revious Nov 20 '20 at 13:13