Shortcut Menu Overview

Shortcut menus appear when the user taps the stylus at a point on the screen and holds it down for a short period. When the stylus is held down in a position served by a shortcut menu, animated feedback around the point of the stylus signals that a shortcut menu is going to appear. The tap-and-hold gesture for displaying shortcut menus is recognized by using the SHRecognizeGesture function in the WM_LBUTTONDOWN message handler.

The shortcut menu provides commands that are useful in the context of the object under the stylus. For example, common shortcut menu commands are Cut, Copy, Paste, and Refresh.

The menu can be displayed from an existing menu resource or constructed dynamically by using the Windows Management AppendMenu function. You can also dynamically add items to an existing menu resource. Dynamically adding items to the menu is slower than using a predefined resource but is an option if you need to create such dynamic behavior.

If you want to customize file lists with your own menu options, you can extend shortcut menus that appear in any application, including those in Microsoft Pocket Office. You can also add desktop style extensions for specific file types. For example, you can give users additional context sensitive options when they tap and hold documents in Pocket Word or when they tap and hold files in Pocket File Explorer.

A shortcut menu extension is implemented as a COM server component. You can use an abstraction interface exposed by the application that you are adding your component to. Your component gets application-specific information through this interface. The shell sets the application's abstraction interface to be the site of your component with a call to your implementation of IObjectWithSite::SetSite.

Note   Using CePIMCommand to create Pocket Outlook menu add-ins has been deprecated. Use the IContextMenu interface instead.

When the user opens a menu containing your extension, the shell calls your implementation of IContextMenu::QueryContextMenu to show the new commands your extension makes available. When the user selects one of the new commands, the application calls SHInvokeContextMenuCommand, which in turn calls your implementation of IContextMenu::InvokeCommand. Your component gets a reference to the application abstraction interface by calling your implementation of IObjectWithSite::GetSite.

The following table details information about where you can extend shortcut menus in the Windows Mobile-based Pocket PC user interface. In the User interface column, Summary screen refers to the window that shows the existing list of files created by the application. Main screen refers to the editable window that provides core application functionality — for example, the blank document that appears when you tap New on the Pocket Excel summary screen.

Note   IOleWindow is simply a wrapper around a window handle. IDataObject is used by your component to get data that has an associated clipboard format. For more information, see How to: Implement IDataObject.

User interface Context Class Interface Clipboard format Header file
Input panel preference, edit controls Shell Edit IOleWindow None None
Main screen, View menu Contacts Main_View IDataObject CFNAME_ITEMREFARRAY appext.h
Main screen, shortcut menu Contacts Main_ContextMenu IDataObject CFNAME_ITEMREFARRAY appext.h
Main screen, Tools menu Contacts Main_Tools IDataObject CFNAME_ITEMREFARRAY appext.h
Summary screen, Tools menu Contacts Summary_Tools IDataObject CFNAME_ITEMREFARRAY appext.h
Edit screen, Edit menu Contacts Edit_Edit IDataObject CFNAME_ITEMREFARRAY appext.h
Main screen, shortcut menu Calendar Main_ContextMenu IDataObject CFNAME_ITEMREFARRAY appext.h
Edit screen, Edit menu Calendar Edit_Edit IDataObject CFNAME_ITEMREFARRAY appext.h
Main screen, Tools menu Calendar Main_Tools IDataObject CFNAME_ITEMREFARRAY appext.h
Summary screen, Tools menu Calendar Summary_Tools IDataObject CFNAME_ITEMREFARRAY appext.h
Main screen, shortcut menu Tasks Main_ContextMenu IDataObject CFNAME_ITEMREFARRAY appext.h
Edit screen, Edit menu Tasks Edit_Edit IDataObject CFNAME_ITEMREFARRAY appext.h
Main screen, Tools menu Tasks Main_Tools IDataObject CFNAME_ITEMREFARRAY appext.h
Summary screen, Tools menu Tasks Summary_Tools IDataObject CFNAME_ITEMREFARRAY appext.h
Imaging, Thumbnail view Pictures Imagefile IDataObject CF_HDROP None
Main screen, Tools menu Inbox Main IOleWindow None None
Device, Active Sync, Tools menu ActiveSync ActiveSyncConnect None None None

See Also

How to: Display a Shortcut Menu from an Existing Resource

How to: Extend Shortcut Menus

How to: Implement IContextMenu and IObjectWithSite

How to: Implement IDataObject

How to: Prevent Tap-and-Hold Animation Display

How to: Register a File System Shortcut Menu

Send feedback on this topic to the authors.

© 2005 Microsoft Corporation. All rights reserved.