afx _ msg void OnNetPortSet(void);
Add to source file
BEGIN_MESSAGE_MAP(CMainFrame,CFrameWndEx)
ON_COMMAND(ID_MODIFYPORT,& ampCMainFrame::OnNetPortSet)
END_MESSAGE_MAP()
ID_MODIFYPORT is the ID number of the menu item, and the message processing function OnNetPortSet () of the menu item. You can add what the user did after selecting one of the menu items.
If you want the menu items in the pop-up menu to be grayed out, please use the following function to enable menuitem (m _ hmainmenu, i, MF _ byposition | MF _ grayed).
Specific functions are described as follows.
Allows or disables the specified menu item.
BOOL EnableMenuItem(HMENU hMenu,UINT uIDEnableItem,UINT uEnable);
Return value: BOOL judges whether it is successful or not.
Parameter list:
Parameter type and description
Menu handle
WIDEnableItem, the identifier of the allowed or prohibited menu item. If the MF_BYCOMMAND flag is set in the wEnable parameter, this parameter indicates the command ID of the menu item to be changed. If MF_BYPOSITION is set, this parameter indicates the position of the menu item (the first item must be zero).
WEnable, refer to the menu constant flag definition table in the ModifyMenu function, which lists all allowed constants. Only the following constants can be specified for this function: MF_BYCOMMAND, MF_BYPOSITION, MF_ENABLED, MF_DISABLED and MF_GRAYED.
These values have the following meanings:
The MF _ byCommand specified parameter gives the command ID number of the existing menu item. This is the default value.
MF _ Byposition specifies that the parameter gives the location of the existing menu item. The position of the first item is 0.
MF _ Disabled invalidates the menu item so that it cannot be selected, but it is not grayed out.
MF _ enabled makes the menu item valid, so that it can be selected and restored from the grayed-out state.
MF _ grayed invalidates the menu item so that it cannot be selected and grayed out at the same time.