Microsoft KB Archive/252610

{|
 * width="100%"|

HOWTO: Use Drop-Down Toolbar Buttons in a Shell Namespace Extension

 * }

Q252610

-

The information in this article applies to:


 * Microsoft Win32 Application Programming Interface (API)

-

SUMMARY
The view of a shell namespace extension can add items to the Windows Explorer toolbar by calling IShellBrowser::SetToolbarItems. When the Desktop Update was introduced, the capability to add drop-down toolbar items (BTNS_DROPDOWN or TBSTYLE_DROPDOWN) was also added. The problem is that Windows Explorer does not forward the TBN_DROPDOWN notifications to the view window, so there has not been any clear way for the view to respond to the drop-down button. This article describes how Windows Explorer actually does notify the view that a drop-down button has been pressed and how the view can react to it.

MORE INFORMATION
Windows Explorer does not forward the TBN_DROPDOWN notification directly, but it does send a WM_COMMAND message to the view. The WPARAM of this message contains the command identifier of the toolbar button, and the LPARAM contains a pointer to a private data structure. This structure contains the rectangle of the toolbar button, in screen coordinates. Generally, this is all the information that is necessary for the view to respond to the drop-down notification. The structure of this data is:

typedef struct {   HWND        hwndFrom; VARIANTARG *pva; DWORD      dwUnused; }TBDDDATA, *LPTBDDDATA; The hwndFrom member of this structure usually contains the window handle of the browser. However, it may instead contain the handle to a different window, so this possibility must be taken into account.

The pva member of this structure is of VT_INT_PTR type and the byref member of the VARIANT contains the rectangle of the toolbar button.

The dwUnused member of this structure is not used and should be 0.

If you want to display a pop-up menu under the drop-down toolbar button, you can use code like the following to do so:

LPTBDDDATA ptbd = (LPTBDDDATA)lParam; if(VT_INT_PTR == ptbd->pva->vt) {  HMENU hMenu  = CreatePopupMenu; if(hMenu) {     LPRECT   prc = (LPRECT)ptbd->pva->byref; AddYourMenuItems(hMenu); //Private function that adds the items to the popup menu. TrackPopupMenu(hMenu, TPM_LEFTALIGN, prc->left, prc->bottom, 0, hwndView, NULL); DestroyMenu(hMenu); }  } Additional query words:

Keywords : kbExtension kbNameSpace kbSDKWin32 kbShellGrp kbDSupport

Issue type : kbhowto

Technology : kbAudDeveloper kbWin32sSearch kbWin32API