Newsflash

Add your items to Windows Explorer context menu - it never was easier: Windows Explorer Context Menu v6.83 was released

Read more...
 

Full Vista support appended

Read more...
 
Home arrow Archive arrow IContextMenu::QueryContextMenu Method
IContextMenu::QueryContextMenu Method PDF Print E-mail
IContextMenu::QueryContextMenu Method

Adds commands to a shortcut menu.

Add items to Explorer Shell context (right-click) menu easily – How ?

 

 

 Add entries to Explorer Shell context menu with Windows Explorer Shell Context Menu

 

  Add items to Windows Explorer context menu easily with Windows Explorer Context Menu. This powerful .Net component for custom items adding to Windows Explorer context menu will append all your application entries to Explorer context menu. It , C++ and Visual Basic .NET support include detailed C# and VB.NET samples, tutorials and support all you may need :

  • Add items to Windows Explorer context menu to be shown on any Windows computer (all operating systems are supported – XP, Vista, Windows x64 , etc.)
  • Add items to Windows Explorer context menu to be shown in any way - with custom caption and your custom icon, as separator or sub-menu
  • Add items to Explorer Shell context menu to be shown for all types of files or shown only for computer files of particular type (for example, only for .PDF .TXT , .MP3,.WMA,.AAC , .AVI files)
  • Add your program entries to Explorer context menu, sub-menus, sub-sub-menus, sub-menus of unlimited depth and even much more


Windows Explorer Shell Context Menu - is a .Net component that support all you need to add your program items to Windows Explorer Shell context menu - in a fast and easy way. Add your application entries to Windows Explorer context menu right now – add entries to context menu fast and exactly as you prefere :

 Insert an item To the Windows Explorer Context Menus very easy with Windows Explorer Shell Context Menu

 

QueryContextMenu is an unmanaged method used on old operating systems from Windows 3.1 (Windows for Workgroups) to add items to context menu of Windows Explorer, because QueryContextMenu method works only for Windows 95 / Windows 98 (not on XP, Vista, x64 - 64-bit Windows), to append items to Windows Explorer context menu you should use, according to Microsoft guidelines, appropriate .Net component - Explorer Context Menu. It will help to add your items to Explorer context menu - fast, easy and exactly as you want.

 

Syntax

    HRESULT QueryContextMenu(      
        HMENU hmenu,
        UINT indexMenu,
        UINT idCmdFirst,
        UINT idCmdLast,
        UINT uFlags
    );


Parameters

    hmenu
        A handle to the menu. The handler should specify this handle when adding menu items.
    indexMenu
        The zero-based position at which to insert the first menu item.
    idCmdFirst
        The minimum value that the handler can specify for a menu item identifier.
    idCmdLast
        The maximum value that the handler can specify for a menu item identifier.
    uFlags
        Optional flags specifying how the shortcut menu can be changed. This parameter can be set to any combination of the following values. The remaining bits of the low-order word are reserved by the system. The high-order word can be used for context-specific communications. The CMF_RESERVED value can be used to mask out the low-order word.

        CMF_CANRENAME
            This flag is set if the calling application supports renaming of items. A shortcut menu extension or drag-and-drop handler should ignore this flag. A namespace extension should add a rename item to the menu if applicable.
        CMF_DEFAULTONLY
            This flag is set when the user is activating the default action, typically by double-clicking. This flag provides a hint for the shortcut menu extension to add nothing if it does not modify the default item in the menu. A shortcut menu extension or drag-and-drop handler should not add any menu items if this value is specified. A namespace extension should add only the default item (if any).
        CMF_DISABLEDVERBS
            Windows Vista and later: This flag is set when the calling application wants to invoke verbs that are otherwise disabled, such as legacy menus.
        CMF_EXPLORE
            This flag is set when the Microsoft Windows Explorer tree window is present.
        CMF_EXTENDEDVERBS
            This flag is set when the calling application wants extended verbs. Normal verbs are displayed when the user right-clicks an object. To display extended verbs, the user must right-click while pressing the SHIFT key.
        CMF_INCLUDESTATIC
            Not supported under Windows Vista and later: This flag is set when a static menu is being constructed. Only the browser should use this flag. All other shortcut menu extensions should ignore this flag.
        CMF_ITEMMENU
            Windows Vista and later: This flag is set when the calling application is invoking a context menu on an item in the view (as opposed to the background of the view).
        CMF_NODEFAULT
            This flag is set if no item in the menu has been set as the default. A drag-and-drop handler should ignore this flag. A namespace extension should not set any of the menu items to the default.
        CMF_NORMAL
            Indicates normal operation. A shortcut menu extension, namespace extension, or drag-and-drop handler can add all menu items.
        CMF_NOVERBS
            This flag is set for items displayed in the Send To menu. Shortcut menu handlers should ignore this value.
        CMF_RESERVED
            This flag is a bitmask that specifies all bits that should not be used. This is to be used only as a mask. Do not pass this as a parameter.
        CMF_VERBSONLY
            This flag is set if the shortcut menu is for a shortcut object. Shortcut menu handlers should ignore this value.


Return Value

    If successful, returns an HRESULT value that has its severity value set to SEVERITY_SUCCESS and its code value set to the offset of the largest command identifier that was assigned, plus one. For example, if idCmdFirst is set to 5 and you add three items to the menu with command identifiers of 5, 7, and 8, the return value should be MAKE_HRESULT(SEVERITY_SUCCESS, 0, 8 - 5 + 1). Otherwise, it returns a COM error value.


Remarks

    This method should call either InsertMenu or InsertMenuItem to insert its menu items into the menu specified by hmenu. The indexMenu parameter holds the index to be used for the first menu item. The identifier of each menu item must fall within the range defined by idCmdFirst and idCmdLast.

    A common practice is to set the first command identifier to idCmdFirst (an offset of zero) and increment the offset for each additional command by one. This practice ensures that you do not exceed idCmdLast and preserves the range of identifiers that are available for use by other handlers. Store the offsets for reference because they can be used to identify the command in subsequent calls to IContextMenu::GetCommandString and IContextMenu::InvokeCommand.

    If the Shell subsequently calls another shortcut menu handler, it will use the code value of the returned HRESULT to set idCmdFirst when it calls that handler's QueryContextMenu method.

    When a context menu handler adds a pop-up menu item, it must use IContextMenu::QueryContextMenu to add at least one item to that menu for the WM_INITMENUPOPUP message to be forwarded.

 
< Prev   Next >
© 2012 Add items to Windows Context Menu - easily with Windows Explorer Context Menu (.Net Component)
All product and company names are trademarks or registered trademarks of their respective owners.