网站首页  词典首页

请输入您要查询的函数:

 

术语 modifymenu
释义 ModifyMenu
语法:
BOOL ModifyMenu( HMENU hMnu,
UINT uPosition,
UINT uFlags,
PTR uIDNewItem,
LPCTSTR lpNewItem
);
ModifyMenu函数
该ModifyMenu功能改变现有的菜单项。此功能用于指定的内容,外观和菜单项的行为。
参数
hMnu
[in]句柄菜单改变。
uPosition
[in]指定菜单项的改变,由uFlags参数确定。
uFlags
[in]指定的标志控制的诠释uPosition参数和内容,外观和菜单项的行为。此参数必须是下列规定值之一组合,至少在以下备注一节中列出的值。
MF_BYCOMMAND
表明uPosition参数给出了菜单项的标识符。该MF_BYCOMMAND标志是,如果既不是MF_BYCOMMAND或MF_BYPOSITION标志指定的默认。
MF_BYPOSITION
表明uPosition参数给出了基于零的菜单项的相对位置。
uIDNewItem
[in]指定或修改后的菜单项的标识,或如uFlags参数有MF_POPUP标志集,一个句柄下拉菜单或子菜单下拉。
lpNewItem
[in]指向变化了的菜单项的内容。这个参数的解释取决于是否uFlags参数包括MF_BITMAP,MF_OWNERDRAW,或MF_STRING标志。
MF_BITMAP
包含一个位图句柄。
MF_OWNERDRAW
载有一个是用于维护相关的菜单项的附加数据的应用提供一个值。在价值结构的ItemData成员,指出由WM_MEASUREITEM和WM_DRAWITEM lParam参数发送的邮件时,该菜单项创建或其外观被更新。
MF_STRING
它包含一个指向一个空结束的字符串(默认值)。
返回值
如果函数成功,返回值为非零。
如果函数失败,返回值是零。为了获得更多错误信息,调用GetLastError。
备注
注意ModifyMenu功能已被取代了SetMenuItemInfo功能。您仍然可以使用ModifyMenu,但是,如果您不需要的SetMenuItemInfo扩展的任何功能。
如果ModifyMenu取代了菜单项,打开一个下拉菜单或子菜单式,功能破坏了旧的菜单或子菜单式并释放它所使用的内存。
在键盘加速器为了与位图或自行绘制的菜单项,菜单的拥有者必须处理WM_MENUCHAR消息。见所有者描述的菜单和有关更多信息,WM_MENUCHAR消息。
应用程序必须调用函数DrawMenuBar每当菜单更改,是否在菜单上显示的窗口。要改变现有的菜单项的属性,它要快得多使用CheckMenuItem和EnableMenuItem功能。
下面的列表描述了可能在uFlags参数设置的标志。
ValueMeaning
MF_BITMAPUses位图的菜单项。该lpNewItem参数包含一个位图句柄。
MF_BYCOMMANDIndicates的uPosition参数指定的菜单项(默认值)的标识符。
MF_BYPOSITIONIndicates的uPosition参数指定了从零开始的新菜单项的相对位置。
MF_CHECKEDPlaces旁打勾的项目。如果您的应用提供了检查标记位图(见SetMenuItemBitmaps函数),这标志显示所选位图旁边的菜单项。
MF_DISABLEDDisables菜单项,以便它不能被选中,但没有这个标志是灰色。
MF_ENABLEDEnables菜单项,以便它可以选择,并恢复其灰色状态。
MF_GRAYEDDisables的菜单项,格雷斯,使它不能被选中。
MF_MENUBARBREAKFunctions作为一个菜单栏MF_MENUBREAK标志相同。对于一个下拉菜单,子菜单或快捷菜单,新列下拉分开旧列由垂直线。
MF_MENUBREAKPlaces的项目在一个新行(菜单栏),或在一个新的列(下拉菜单,子菜单或快捷菜单中)没有分离列。
MF_OWNERDRAWSpecifies该项目是一个所有者描述的项目。之前菜单首次显示,窗口,拥有菜单收到WM_MEASUREITEM消息检索的宽度和高度的菜单项。在WM_DRAWITEM消息,然后发送到主人的窗口的窗口过程时,该菜单项的外观必须更新。
MF_POPUPSpecifies该菜单项打开一个下拉菜单或子菜单下拉。在uIDNewItem参数指定一个句柄下拉菜单或子菜单下拉。这个标志是用来添加一个菜单名字命名的菜单栏或菜单项,打开子菜单的下拉菜单,子菜单或快捷菜单。
MF_SEPARATORDrawsLevel的分界线。这个标志只用于在一个下拉菜单,子菜单或快捷菜单。该生产线不能变灰,残疾,或强调。在lpNewItem和uIDNewItem参数将被忽略。
MF_STRINGSpecifies该菜单项是一个文本字符串;的lpNewItem参数是一个字符串指针。
MF_UNCHECKEDDoes不把旁打勾的项目(默认值)。如果您的应用程序提供检查标记位图(见SetMenuItemBitmaps函数),这标志显示清晰的位图旁边的菜单项。
旗帜以下组不能一起使用:
MF_BYCOMMAND和MF_BYPOSITION
MF_DISABLED,MF_ENABLED和MF_GRAYED
MF_BITMAP,MF_STRING,MF_OWNERDRAW和MF_SEPARATOR
MF_MENUBARBREAK和MF_MENUBREAK
MF_CHECKED和MF_UNCHECKED
在Windows 95/98/Me:ModifyMenuW是支持的Unicode(MSLU)微软层。要使用此,您必须将某些文件到您的应用,概述了对Unicode的Microsoft层在Windows 95/98/Me系统。
例如
有关示例,请参阅设置菜单字体项目的文本字符串。
功能信息
最低DLL版本 user32.dll
在Winuser.h中HeaderDeclared,头文件:winuser.h
import libraryUser32.lib
最低操作系统Windows 95,Windows NT 3.1
UnicodeImplemented为ANSI和Unicode版本。
参见
菜单,AppendMenu,CheckMenuItem,DrawMenuBar,EnableMenuItem,SetMenuItemBitmaps,SetMenuItemInfo,WM_DRAWITEM,WM_MEASUREITEM
==英文原文==ModifyMenu Function
The ModifyMenu function changes an existing menu item. This function is used to specify the content, appearance, and behavior of the menu item.
Syntax
BOOL ModifyMenu( HMENU hMnu,
UINT uPosition,
UINT uFlags,
PTR uIDNewItem,
LPCTSTR lpNewItem
);
Parameters
hMnu
[in] Handle to the menu to be changed.
uPosition
[in] Specifies the menu item to be changed, as determined by the uFlags parameter.
uFlags
[in] Specifies flags that control the interpretation of the uPosition parameter and the content, appearance, and behavior of the menu item. This parameter must be a combination of one of the following required values and at least one of the values listed in the following Remarks section.
MF_BYCOMMAND
Indicates that the uPosition parameter gives the identifier of the menu item. The MF_BYCOMMAND flag is the default if neither the MF_BYCOMMAND nor MF_BYPOSITION flag is specified.
MF_BYPOSITION
Indicates that the uPosition parameter gives the zero-based relative position of the menu item.
uIDNewItem
[in] Specifies either the identifier of the modified menu item or, if the uFlags parameter has the MF_POPUP flag set, a handle to the drop-down menu or submenu.
lpNewItem
[in] Pointer to the content of the changed menu item. The interpretation of this parameter depends on whether the uFlags parameter includes the MF_BITMAP, MF_OWNERDRAW, or MF_STRING flag.
MF_BITMAP
Contains a bitmap handle.
MF_OWNERDRAW
Contains a value supplied by an application that is used to maintain additional data related to the menu item. The value is in the itemData member of the structure pointed to by the lParam parameter of the WM_MEASUREITEM or WM_DRAWITEM messages sent when the menu item is created or its appearance is updated.
MF_STRING
Contains a pointer to a null-terminated string (the default).
Return Value
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, call GetLastError .
Remarks
Note The ModifyMenu function has been superseded by the SetMenuItemInfo function. You can still use ModifyMenu, however, if you do not need any of the extended features of SetMenuItemInfo.
If ModifyMenu replaces a menu item that opens a drop-down menu or submenu, the function destroys the old drop-down menu or submenu and frees the memory used by it.
In order for keyboard accelerators to work with bitmap or owner-drawn menu items, the owner of the menu must process the WM_MENUCHAR message. See Owner-Drawn Menus and the WM_MENUCHAR Message for more information.
The application must call the DrawMenuBar function whenever a menu changes, whether or not the menu is in a displayed window. To change the attributes of existing menu items, it is much faster to use the CheckMenuItem and EnableMenuItem functions.
The following list describes the flags that may be set in the uFlags parameter.
ValueMeaning
MF_BITMAPUses a bitmap as the menu item. The lpNewItem parameter contains a handle to the bitmap.
MF_BYCOMMANDIndicates that the uPosition parameter specifies the identifier of the menu item (the default).
MF_BYPOSITIONIndicates that the uPosition parameter specifies the zero-based relative position of the new menu item.
MF_CHECKEDPlaces a check mark next to the item. If your application provides check-mark bitmaps (see the SetMenuItemBitmaps function), this flag displays a selected bitmap next to the menu item.
MF_DISABLEDDisables the menu item so that it cannot be selected, but this flag does not gray it.
MF_ENABLEDEnables the menu item so that it can be selected and restores it from its grayed state.
MF_GRAYEDDisables the menu item and grays it so that it cannot be selected.
MF_MENUBARBREAKFunctions the same as the MF_MENUBREAK flag for a menu bar. For a drop-down menu, submenu, or shortcut menu, the new column is separated from the old column by a vertical line.
MF_MENUBREAKPlaces the item on a new line (for menu bars) or in a new column (for a drop-down menu, submenu, or shortcut menu) without separating columns.
MF_OWNERDRAWSpecifies that the item is an owner-drawn item. Before the menu is displayed for the first time, the window that owns the menu receives a WM_MEASUREITEM message to retrieve the width and height of the menu item. The WM_DRAWITEM message is then sent to the window procedure of the owner window whenever the appearance of the menu item must be updated.
MF_POPUPSpecifies that the menu item opens a drop-down menu or submenu. The uIDNewItem parameter specifies a handle to the drop-down menu or submenu. This flag is used to add a menu name to a menu bar or a menu item that opens a submenu to a drop-down menu, submenu, or shortcut menu.
MF_SEPARATORDraws a horizontal dividing line. This flag is used only in a drop-down menu, submenu, or shortcut menu. The line cannot be grayed, disabled, or highlighted. The lpNewItem and uIDNewItem parameters are ignored.
MF_STRINGSpecifies that the menu item is a text string; the lpNewItem parameter is a pointer to the string.
MF_UNCHECKEDDoes not place a check mark next to the item (the default). If your application supplies check-mark bitmaps (see the SetMenuItemBitmaps function), this flag displays a clear bitmap next to the menu item.
The following groups of flags cannot be used together:
MF_BYCOMMAND and MF_BYPOSITION
MF_DISABLED, MF_ENABLED, and MF_GRAYED
MF_BITMAP, MF_STRING, MF_OWNERDRAW, and MF_SEPARATOR
MF_MENUBARBREAK and MF_MENUBREAK
MF_CHECKED and MF_UNCHECKED
Windows 95/98/Me: ModifyMenuW is supported by the Microsoft Layer for Unicode (MSLU). To use this, you must add certain files to your application, as outlined in Microsoft Layer for Unicode on Windows 95/98/Me Systems .
Example
For an example, see Setting Fonts for Menu-Item Text Strings .
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 ANSI and Unicode versions.
See Also
Menus , AppendMenu , CheckMenuItem , DrawMenuBar , EnableMenuItem , SetMenuItemBitmaps , SetMenuItemInfo , WM_DRAWITEM , WM_MEASUREITEM
==原始网址==http://msdn.microsoft.com/en-us/library/ms647993(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 9:21:35