{"id":20103,"date":"2008-11-24T10:00:00","date_gmt":"2008-11-24T10:00:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/2008\/11\/24\/consequences-of-the-explorer-view-model-if-you-create-a-view-then-you-succeeded-even-if-youd-rather-fail\/"},"modified":"2008-11-24T10:00:00","modified_gmt":"2008-11-24T10:00:00","slug":"consequences-of-the-explorer-view-model-if-you-create-a-view-then-you-succeeded-even-if-youd-rather-fail","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20081124-00\/?p=20103","title":{"rendered":"Consequences of the Explorer view model: If you create a view, then you succeeded, even if you&#8217;d rather fail"},"content":{"rendered":"<p>Commenter Anonymous asked <a href=\"http:\/\/blogs.msdn.com\/oldnewthing\/archive\/2005\/06\/10\/427696.aspx#427726\"> why navigating to a drive with no media displays a dialog instead of showing the error message in the view<\/a>.<\/p>\n<p> This is an unfortunate consequence of Explorer&#8217;s browser\/view model. The shell browser binds to the <code>IShellFolder<\/code> and asks for the view by calling <code>IShellFolder::CreateViewWindow<\/code>. The view window calls <code>IShellFolder::EnumObjects<\/code> to figure out what to show in the view&mdash;and here is where the error dialog appears asking you to insert a disc into the drive. <\/p>\n<p> The problem is that <code>IShellFolder::EnumObjects<\/code> has to return an enumerator or an error code. There is no return value that says &#8220;Um, yeah, could you display this text instead?&#8221; In a narrow sense, there&#8217;s no way to return it since there is no way to return a string from <code>IShellFolder::EnumObjects<\/code>, but it&#8217;s also not possible in a broader sense, since there is no rule that says only shell views can call <code>IShellFolder::EnumObjects<\/code>. Anybody can bind to a shell folder and enumerate its contents. And most of them don&#8217;t have any place to display a text message instead of the enumerated objects. For example, the folder tree uses <code>IShellFolder::EnumObjects<\/code> to fill in children of a node. If you expand a node for an empty floppy drive, where is the &#8220;Sorry&#8221; message supposed to appear? <\/p>\n<p> Now, you might say, &#8220;Well, make a special case for Explorer,&#8221; and maybe that&#8217;s the right thing to do, but designing in a special case to a general interface just for one program tends to create resentment for others: &#8220;How come Explorer can do this but my program can&#8217;t?&#8221; <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Commenter Anonymous asked why navigating to a drive with no media displays a dialog instead of showing the error message in the view. This is an unfortunate consequence of Explorer&#8217;s browser\/view model. The shell browser binds to the IShellFolder and asks for the view by calling IShellFolder::CreateViewWindow. The view window calls IShellFolder::EnumObjects to figure out [&hellip;]<\/p>\n","protected":false},"author":1069,"featured_media":111744,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[25],"class_list":["post-20103","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-code"],"acf":[],"blog_post_summary":"<p>Commenter Anonymous asked why navigating to a drive with no media displays a dialog instead of showing the error message in the view. This is an unfortunate consequence of Explorer&#8217;s browser\/view model. The shell browser binds to the IShellFolder and asks for the view by calling IShellFolder::CreateViewWindow. The view window calls IShellFolder::EnumObjects to figure out [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/20103","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/users\/1069"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/comments?post=20103"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/20103\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media\/111744"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media?parent=20103"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=20103"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=20103"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}