Microsoft KB Archive/184780

= SAMPLE: IEFavMnu.exe Create an Internet Explorer 4.0 Favorite =

Article ID: 184780

Article Last Modified on 8/5/2004

-

APPLIES TO


 * Microsoft Internet Explorer 4.0 128-Bit Edition
 * Microsoft Internet Explorer 4.01 Service Pack 2

-



This article was previously published under Q184780



SUMMARY
IEFavMnu demonstrates how to enumerate the Favorites folder and create a Favorites menu. This sample hosts the WebBrowser control in order to facilitate testing of the Favorites menu. Channels and Shell Links are also included in the Favorites menu just as in Internet Explorer 4.0x.



MORE INFORMATION
The following file is available for download from the Microsoft Download Center:

IEFavMnu.exe

For additional information about how to download Microsoft Support files, click the following article number to view the article in the Microsoft Knowledge Base:

119591 How to Obtain Microsoft Support Files from Online Services

Microsoft scanned this file for viruses. Microsoft used the most current virus-detection software that was available on the date that the file was posted. The file is stored on security-enhanced servers that help to prevent any unauthorized changes to the file. IEFavMnu enumerates the Favorites folder and adds the name of each item to the Favorites menu. Also, the Uniform Resource Locator (URL) to which the favorite points is added to a CStringArray object. When the user chooses a favorite from the Favorites menu, the CStringArray is used to determine where to navigate.

IEFavMnu performs the following steps in order to enumerate the Favorites folder and create the Favorites menu:
 * 1) Get a pointer to an identifier list (PIDL) for the Favorites folder by calling the SHGetSpecialFolderLocation function.
 * 2) Enumerate all objects in the Favorites folder using the IShellFolder::EnumObjects method.
 * 3) Get the display name of the favorite by calling the IShellFolder::GetDisplayNameOf method.
 * 4) If the item is a folder, create a new submenu. The function that creates the Favorites menu then calls itself again in order to enumerate the subfolder.

If the item is not a folder, it is added to the current menu.
 * 1) Get the actual URL of the favorite. This is different depending on if the item is an internet shortcut, a channel shortcut, a link, and so forth.
 * 2) Add the URL of the favorite to a CStringArray that holds the URLs for all the favorites.

IEFavMnu assigns a range of command IDs to the favorites in the menu. Currently this range is from 33000 to 35000. This means that if the user has more than 2000 favorites, attempts to navigate to any favorite after number 2000 will fail. This range of command IDs maps to the OnFavoritesURL method. A range of command IDs is mapped to a method by using the ON_COMMAND_RANGE macro in the message map.

When the user chooses a favorite from the menu, the OnFavoritesURL method is called. Then the IWebBrowser2::Navigate method is called with the URL of the favorite which is retrieved from the CStringArray. The offset into the CStringArray that contains the URL of the selected favorite is determined by subtracting the ID of the first favorite from the command ID that is sent to the OnFavoritesURL method.

Additional query words: Favorite ShellLink Channel IEFavMnu

Keywords: kbinfo kbdownload kbfile kbsample KB184780

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.