windows_programming_notes.nbk: Home | Index | Next Page: TranslateAccelerator | Previous Page: TrackPopupMenu


 TrackPopupMenuEx

The TrackPopupMenuEx function displays a shortcut menu at the specified location and tracks the selection of items on the shortcut menu. The shortcut menu can appear anywhere on the screen.

Syntax

    BOOL TrackPopupMenuEx(
        HMENU hmenu,
        UINT fuFlags,
        int x,
        int y,
        HWND hwnd,
        LPTPMPARAMS lptpm
    );

Parameters

Return Value

If you specify TPM_RETURNCMD in the fuFlags parameter, the return value is the menu-item identifier of the item that the user selected. If the user cancels the menu without making a selection, or if an error occurs, then the return value is zero.

If you do not specify TPM_RETURNCMD in the fuFlags parameter, the return value is nonzero if the function succeeds and zero if it fails. To get extended error information, call GetLastError.

Remarks

Note Call GetSystemMetrics(SM_MENUDROPALIGNMENT) to determine the correct horizontal alignment flag (TPM_LEFTALIGN or TPM_RIGHTALIGN) and/or horizontal animation direction flag (TPM_HORPOSANIMATION or TPM_HORNEGANIMATION) to pass to TrackPopupMenu or TrackPopupMenuEx. This is essential for creating an optimal user experience, especially when developing Microsoft Tablet PC applications. To display a context menu for a notification icon, the current window must be the foreground window before the application calls TrackPopupMenu or TrackPopupMenuEx. Otherwise, the menu will not disappear when the user clicks outside of the menu or the window that created the menu (if it is visible).

Function Information


windows_programming_notes.nbk: Home | Index | Next Page: TranslateAccelerator | Previous Page: TrackPopupMenu


Notebook exported on Monday, 7 July 2008, 18:56:50 PM Eastern Daylight Time