网站首页  词典首页

请输入您要查询的函数:

 

术语 trackpopupmenu
释义 TrackPopupMenu
语法:
BOOL TrackPopupMenu( HMENU hMenu,
UINT uFlags,
int x,
int y,
int nReserved,
HWND hWnd,
CONST RECT * prcRect
);
TrackPopupMenu函数
在TrackPopupMenu函数显示在指定位置的快捷菜单,并跟踪菜单项的选择。可以在快捷菜单上的任何地方出现在屏幕上。
参数
hMenu
[in]句柄快捷菜单显示。句柄可以通过调用CreatePopupMenu创建一个新的快捷菜单,或调用GetSubMenu来检索处理,与现有的菜单项关联的子获得。
uFlags
[in]使用这些标志的零发展到指定的功能选项。
使用下列标志之一指定位置的功能快捷菜单上的Level。
TPM_CENTERALIGN
如果设置此标志,函数中心的快捷菜单Level相协调的x参数指定。
TPM_LEFTALIGN
如果设置此标志,函数的快捷菜单,以便其左侧是与坐标的x参数指定的一致立场。
TPM_RIGHTALIGN
位置的快捷菜单,以便其右侧是与坐标的x参数指定的一致。
使用下列标志之一指定位置的功能快捷菜单上的垂直。
TPM_BOTTOMALIGN
如果设置此标志,函数的快捷菜单,以便其底部是与坐标的y参数指定的一致立场。
TPM_TOPALIGN
如果设置此标志,函数的快捷菜单,以便其顶面是与坐标的y参数指定的一致立场。
TPM_VCENTERALIGN
如果设置此标志,函数中心的快捷菜单垂直相对的y坐标参数指定。
使用以下标志来确定,而不必设立菜单父窗口的用户选择。
TPM_NONOTIFY
如果这个标志被设置,该函数不发送通知消息时,菜单项在用户点击。
TPM_RETURNCMD
如果设置此标志,则函数返回用户的选择菜单中的返回值项的标识符。
使用下列标志之一指定鼠标按钮的快捷菜单上轨道。
TPM_LEFTBUTTON
如果此标志设置,用户可以选择只用鼠标左键菜单项。
TPM_RIGHTBUTTON
如果此标志设置,用户既可以选择左,右鼠标按钮菜单项。
Windows 98/Me中时,Windows 2000/XP的,景色:使用下列任何标志的合理组合,修改菜单的动画。例如,通过选择Level和垂直标志可以实现对角动画。
TPM_HORNEGANIMATION
从右到左菜单富有活力。
TPM_HORPOSANIMATION
富有活力的菜单从左至右。
TPM_NOANIMATION
没有动画显示菜单。
TPM_VERNEGANIMATION
从菜单中富有活力的底部顶部。
TPM_VERPOSANIMATION
富有活力的自上而下的菜单。
对于任何动画出现,使用SystemParametersInfo函数必须设置SPI_SETMENUANIMATION。此外,所有的TPM_ *动画旗帜,除TPM_NOANIMATION,如果忽略淡出动画菜单上,看到SystemParametersInfo SPI_GETMENUFADE标志。
Windows 98/Me中时,Windows 2000/XP的,景色:使用TPM_RECURSE标志显示当另一菜单已经显示一个菜单。这是为了支持在上下文菜单的菜单。
Windows XP,景色:若要从从右到文本布局左,使用TPM_LAYOUTRTL。默认情况下,文本布局左到右。
x
[in]指定快捷菜单上的Level位置,在屏幕坐标。
y
[in]指定快捷菜单上的垂直位置,在屏幕坐标。
nReserved
版权所有;必须为零。
hWnd
[in]的窗口句柄拥有快捷菜单。此窗口接收从菜单中的所有邮件。窗口没有收到从菜单中一个WM_COMMAND消息,直到函数返回。如果您指定在uFlags参数TPM_NONOTIFY,该函数不将消息发送到由hWnd确定的窗口。但是,您仍然必须通过一个窗口处理的HWND。它可以是任何窗口处理您的申请。
prcRect
忽略。
返回值
如果您指定在uFlags参数TPM_RETURNCMD,返回值是菜单项的项目,用户选定的标识符。如果用户取消没有作出选择,或者如果发生错误的菜单,然后返回值是零。
如果您不指定在uFlags参数TPM_RETURNCMD,返回值为非零,如果函数成功和零如果失败。为了获得更多错误信息,调用GetLastError。
备注
注意:呼叫GetSystemMetrics(SM_MENUDROPALIGNMENT),以确定正确的Level对齐标志(TPM_LEFTALIGN或TPM_RIGHTALIGN)和/或Level方向的旗帜动画(TPM_HORPOSANIMATION或TPM_HORNEGANIMATION)要传递给TrackPopupMenu或TrackPopupMenuEx。这对于创造最佳的用户体验,尤其是当微软Tablet PC的开发应用。
要指定一个屏幕上的菜单不应重叠,使用TrackPopupMenuEx功能区
要显示一个通知图标上下文菜单,当前窗口必须在前台窗口,然后在应用程序调用TrackPopupMenu或TrackPopupMenuEx。否则,菜单不会消失,当用户点击之外的菜单或窗口创建菜单(如果它是可见的)。但是,在当前窗口的前台窗口,第二次此菜单显示,它显示,然后立即消失。要纠正这一点,您必须强制任务切换到应用程序的调用TrackPopupMenu。这是通过一种良性的信息发布到窗口或线程,如下面的代码示例所示:
SetForegroundWindow(hDlg);
/ /显示菜单
TrackPopupMenu(hSubMenu,
TPM_RIGHTBUTTON,
pt.x,
pt.y,
0,
hDlg,
空);
PostMessage(hDlg,WM_NULL,0,0);

例如
有关示例,请参见显示一个快捷菜单。
功能信息
最低DLL版本 user32.dll
在Winuser.h中HeaderDeclared,头文件:winuser.h
import libraryUser32.lib
最低操作系统Windows 95,Windows NT 3.1
UnicodeImplemented为Unicode版本。
参见
菜单,CreatePopupMenu,GetSubMenu,TrackPopupMenuEx,WM_COMMAND消息
==英文原文==TrackPopupMenu Function
The TrackPopupMenu function displays a shortcut menu at the specified location and tracks the selection of items on the menu. The shortcut menu can appear anywhere on the screen.
Syntax
BOOL TrackPopupMenu( HMENU hMenu,
UINT uFlags,
int x,
int y,
int nReserved,
HWND hWnd,
CONST RECT * prcRect
);
Parameters
hMenu
[in] Handle to the shortcut menu to be displayed. The handle can be obtained by calling CreatePopupMenu to create a new shortcut menu, or by calling GetSubMenu to retrieve a handle to a submenu associated with an existing menu item.
uFlags
[in] Use zero of more of these flags to specify function options.
Use one of the following flags to specify how the function positions the shortcut menu horizontally.
TPM_CENTERALIGN
If this flag is set, the function centers the shortcut menu horizontally relative to the coordinate specified by the x parameter.
TPM_LEFTALIGN
If this flag is set, the function positions the shortcut menu so that its left side is aligned with the coordinate specified by the x parameter.
TPM_RIGHTALIGN
Positions the shortcut menu so that its right side is aligned with the coordinate specified by the x parameter.
Use one of the following flags to specify how the function positions the shortcut menu vertically.
TPM_BOTTOMALIGN
If this flag is set, the function positions the shortcut menu so that its bottom side is aligned with the coordinate specified by the y parameter.
TPM_TOPALIGN
If this flag is set, the function positions the shortcut menu so that its top side is aligned with the coordinate specified by the y parameter.
TPM_VCENTERALIGN
If this flag is set, the function centers the shortcut menu vertically relative to the coordinate specified by the y parameter.
Use the following flags to determine the user selection without having to set up a parent window for the menu.
TPM_NONOTIFY
If this flag is set, the function does not send notification messages when the user clicks on a menu item.
TPM_RETURNCMD
If this flag is set, the function returns the menu item identifier of the user's selection in the return value.
Use one of the following flags to specify which mouse button the shortcut menu tracks.
TPM_LEFTBUTTON
If this flag is set, the user can select menu items with only the left mouse button.
TPM_RIGHTBUTTON
If this flag is set, the user can select menu items with both the left and right mouse buttons.
Windows 98/Me, Windows 2000/XP, Vista: Use any reasonable combination of the following flags to modify the animation of a menu. For example, by selecting a horizontal and a vertical flag you can achieve diagonal animation.
TPM_HORNEGANIMATION
Animates the menu from right to left.
TPM_HORPOSANIMATION
Animates the menu from left to right.
TPM_NOANIMATION
Displays menu without animation.
TPM_VERNEGANIMATION
Animates the menu from bottom to top.
TPM_VERPOSANIMATION
Animates the menu from top to bottom.
For any animation to occur, the SystemParametersInfo function must set SPI_SETMENUANIMATION. Also, all the TPM_*ANIMATION flags, except TPM_NOANIMATION, are ignored if menu fade animation is on, See the SPI_GETMENUFADE flag in SystemParametersInfo.
Windows 98/Me, Windows 2000/XP, Vista: Use the TPM_RECURSE flag to display a menu when another menu is already displayed. This is intended to support context menus within a menu.
Windows XP, Vista: To have text layout from right-to-left, use TPM_LAYOUTRTL. By default, the text layout is left-to-right.
x
[in] Specifies the horizontal location of the shortcut menu, in screen coordinates.
y
[in] Specifies the vertical location of the shortcut menu, in screen coordinates.
nReserved
Reserved; must be zero.
hWnd
[in] Handle to the window that owns the shortcut menu. This window receives all messages from the menu. The window does not receive a WM_COMMAND message from the menu until the function returns. If you specify TPM_NONOTIFY in the uFlags parameter, the function does not send messages to the window identified by hWnd. However, you must still pass a window handle in hWnd. It can be any window handle from your application.
prcRect
Ignored.
Return Value
If you specify TPM_RETURNCMD in the uFlags 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 uFlags 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 specify an area of the screen the menu should not overlap, use the TrackPopupMenuEx function
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). However, when the current window is the foreground window, the second time this menu is displayed, it displays and then immediately disappears. To correct this, you must force a task switch to the application that called TrackPopupMenu. This is done by posting a benign message to the window or thread, as shown in the following code sample:

SetForegroundWindow(hDlg);
// Display the menu
TrackPopupMenu( hSubMenu,
TPM_RIGHTBUTTON,
pt.x,
pt.y,
0,
hDlg,
NULL);
PostMessage(hDlg, WM_NULL, 0, 0);

Example
For an example, see Displaying a Shortcut Menu .
Function Information
Minimum DLL Versionuser32.dll
HeaderDeclared in Winuser.h, include Windows.h
Import libraryUser32.lib
Minimum operating systemsWindows 95, Windows NT 3.1
UnicodeImplemented as Unicode version.
See Also
Menus , CreatePopupMenu , GetSubMenu , TrackPopupMenuEx , WM_COMMAND
==原始网址==http://msdn.microsoft.com/en-us/library/ms648002(VS.85).aspx\n
随便看

 

windows api函数参考手册包含2258条windows api函数文档,详细介绍nodejs、java、rust调用windows api的方法技巧,是学习windows api编程的入门中文文档。

 

Copyright © 2004-2023 Winrtm.com All Rights Reserved
京ICP备2021023879号-40 更新时间:2024/10/6 13:23:05