Partager via


CMenu::GetMenuString

Copies the label of the specified menu item to the specified buffer.

int GetMenuString( 
   UINT nIDItem, 
   LPTSTR lpString, 
   int nMaxCount, 
   UINT nFlags  
) const; 
int GetMenuString( 
   UINT nIDItem, 
   CString& rString, 
   UINT nFlags  
) const;

Parameters

  • nIDItem
    Specifies the integer identifier of the menu item or the offset of the menu item in the menu, depending on the value of nFlags.

  • lpString
    Points to the buffer that is to receive the label.

  • rString
    A reference to a CString object that is to receive the copied menu string.

  • nMaxCount
    Specifies the maximum length (in characters) of the label to be copied. If the label is longer than the maximum specified in nMaxCount, the extra characters are truncated.

  • nFlags
    Specifies the interpretation of the nIDItem parameter. It can be one of the following values:

    nFlags

    Interpretation of nIDItem

    MF_BYCOMMAND

    Specifies that the parameter gives the command ID of the existing menu item. This is the default if neither MF_BYCOMMAND nor MF_BYPOSITION is set.

    MF_BYPOSITION

    Specifies that the parameter gives the position of the existing menu item. The first item is at position 0.

Return Value

Specifies the actual number of characters copied to the buffer, not including the null terminator.

Remarks

The nMaxCount parameter should be one larger than the number of characters in the label to accommodate the null character that terminates a string.

Example

See the example for CMenu::InsertMenu.

Requirements

Header: afxwin.h

See Also

Reference

CMenu Class

Hierarchy Chart

CMenu::GetMenuState

CMenu::ModifyMenu

GetMenuString