Microsoft KB Archive/819499

= BUG: Using Windows Classic Mode in Windows Explorer Returns Incorrect Value for SelectedItems =

Article ID: 819499

Article Last Modified on 11/26/2007

-

APPLIES TO


 * Microsoft Windows 2000 Standard Edition

-



SYMPTOMS
When you set Windows Explorer to display folders in the Windows Classic mode, the SelectedItems method of the IShellFolderViewDual interface returns an incorrect set of FolderItems.



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.



Steps to Reproduce the Behavior
  Open a text editor such as Notepad, paste the following code into a new file, and then save the file as Sample.cpp : using namespace std;
 * 1) include 
 * 2) include 
 * 3) import 
 * 4) import 
 * 5) include

int _tmain(int argc, TCHAR ** argv) {   CoInitialize(0); try {           SHDocVw::IShellWindowsPtr sw(__uuidof(SHDocVw::ShellWindows)); for (long i = 0; i < sw->Count; ++i) {           if (SHDocVw::IWebBrowser2Ptr ie = sw->Item(i)) {               cout << _com_util::ConvertBSTRToString(ie->LocationURL) << endl; if (Shell32::IShellFolderViewDualPtr view = ie->Document) {                  cout << view->SelectedItems->Count << _T(&quot; selected item(s)&quot;) << endl; }           }        }    }    catch (_com_error const & e)    { cout << e.ErrorMessage << endl; }   CoUninitialize; return 0; }  At a command prompt, compile the file by running the following command: cl /EHsc Sample.cpp  Close all the Windows Explorer windows that are currently open. Right-click Start, and then click Explore to open a Windows Explorer window. On the Tools menu, click Folder Options</li> On theGeneral tab, select the Use Windows classic folders option under Web View, and then click OK.</li> Select a folder that contains many items. In the right pane, select some of the items in this folder.</li> At a command prompt, run the Sample.exe executable (that you generated in step 2).

The output displays the result of the Count property of the FolderItems instance that is returned by the SelectedItems method of IShellFolderViewDual interface.

You expect the output to be the number of items that you have selected in the folder in Windows Explorer from the earlier step. However, the output contains the number of all the items in the folder that was selected in Windows Explorer.</li> When Windows Explorer is inWeb view mode, the folder items that are returned by SelectedItems is correctly set to the FolderItem instances that are selected.

To verify the previous statement in Windows Explorer, on the Tools menu, click Folder options.</li> On the General tab, click the Enable Web content on my desktop option under Web View, and then click OK to close the dialog box.</li> At a command prompt, run Sample.exe (generated in step 2).

The output displays the result of the Count property of the FolderItems instance that is returned by the SelectedItems method of IShellFolderViewDual interface.

The output is, as expected, the number of items that you had selected in the folder.</li></ol>

Alternatively, you can use the FocusedItem method of the IShellFolderViewDual interface to replace the incorrect functionality of the SelectedItems method. The FocusedItem method returns the currently selected item in the folder and restricts your application to a single folder selection in Windows Explorer.

<div class="references_section">