Change Menu Item

3270 5250 VT
Yes Yes Yes
The Change Menu Item function appends, deletes, inserts, modifies, and removes menu items. The client sends the following message to the session to change a menu.
PostMessage( hServerWnd,
             WM_DDE_POKE,
             hClientWnd,
             PackDDElParam(WM_DDE_POKE,
             hData,aCHANGEMENU));
where:
hData
Identifies a handle to a Windows global memory object that contains the requests for changing a menu. The global memory object contains the following structure:
typedef struct tagChangeMenu
{
  unsigned char  poke[(sizeof(DDEPOKE)-1)];
  HWND           hMenu;                    /* Window handle of menu item
  unsigned long  wIDNew;                   /* Menu ID of new menu item
  unsigned short wPosition;                /* The position of menu item
  unsigned short wOperation;               /* Specifies the operation
  unsigned short wFlags;                   /* Specifies the options
  unsigned char  szItemName[1];  /* String of the item
} CHANGEMENU;
 
typedef union tagDDE_CHANGEMENU
{
  DDEPOKE     DDEpoke;
  CHANGEMENU  DDEmenu;
} DDE_CHANGEMENU,*lpDDE_CHANGEMENU;
The following operations are supported:
# MF_APPEND,MF_CHANGE ... MF_BYCOMMANDS are replaced with below commands.
 PCS_INSERT       0x0000   /* Inserts a menu item into a menu.
 PCS_CHANGE       0x0080   /* Modifies a menu item in a menu.
 PCS_APPEND       0x0100   /* Appends a menu item to the end of a menu
 PCS_DELETE       0x0200   /* Deletes a menu item from a menu,
                           /* destroying the menu item.
 PCS_REMOVE       0x1000   /* Removes a menu item from a menu but
                           /* does not destroy the menu item.
 
 PCS_CHECKED      0x0008   /* Places a check mark next to the item.
 PCS_DISABLED     0x0002   /* Disables the menu item so that it cannot
                           /* be selected, but does not gray it.
 PCS_ENABLED      0x0000   /* Enables the menu item so that it can be
                           /* selected and restores from its grayed
                           /* state.
 PCS_GRAYED       0x0001   /* Disables the menu item so that it cannot
                           /* be selected, and grays it.
 PCS_MENUBARBREAK 0x0020   /* Same as PCS_MENUBREAK except that for
                           /* popup menus, separates the new column
                           /* from the old column with a vertical line
 PCS_MENUBREAK    0x0040   /* Places the item on a new line for menu
                           /* bar items. For popup menus, places the
                           /* item in a new column, with no dividing
                           /* line between the columns.
 PCS_SEPARATOR    0x0800   /* Draws a horizontal dividing line. Can
                           /* only be used in a popup menu. This line
                           /* cannot be grayed, disabled, or
                           /* highlighted. The wIDNew and szItemName
                           /* fields are ignored.
 PCS_UNCHAKED     0x0000   /* Does not place a check mark next to the
                           /* item (default).
 
 PCS_BYCOMMAND    0x0000   /* Specifies that the nPosition parameter
                           /* gives the menu item control ID number.
                           /* This is the default if neither item
                           /* control ID number. This is the default
                           /* if neither PCS_BYCOMMAND nor
                           /* PCS_POSITION is set.
 PCS_BYPOSITION   0x0400   /* Specifies that the nPosition parameter
                           /* gives the position of the menu item
                           /* to be deleted rather than an ID number.
If the MF_APPEND is specified in the wOperation field, the following fields must be filled:
hMenu

Identifies the menu to be appended. To append a new item to a pop-up menu, specify the handle that is returned from Personal Communications when the Create Menu Item function is executed. To append a new item to a top-level menu bar, specify NULL.

wIDNew

Specifies the command ID of the new menu item. If a new item is added to the top-level menu bar, the handle of the menu item returned from Personal Communications when Create Menu Item function is executed.

wFlags
The following options can be set:
MF_CHECKED       // Places a check mark next to
                 // the item.
MF_DISABLED      // Disables the menu item so
                 // that it cannot be selected,
                 // but does not gray it.
MF_ENABLED       // Enables the menu item so that
                 // it can be selected and
                 // restores from its grayed
                 // state.
MF_GRAYED        // Disables the menu item so
                 // that it cannot be selected,
                 // and grays it.
MF_MENUBARBREAK  // Same as MF_MENUBREAK except
                 // that for pop-up menus,
                 // separates the new column from
                 // the old column with a
                 // vertical line.
MF_MENUBREAK     // Places the item on a new line
                 // for menu bar items.
                 // For pop-up menus, places the
                 // item in a new column, with
                 // no dividing line between the
                 // columns.
MF_SEPARATOR     // Draws a horizontal dividing
                 // line.  Can only be used in a
                 // pop-up menu.  This line cannot
                 // be grayed, disabled, or
                 // highlighted.  The wIDNew and
                 // szItemName fields are
                 // ignored.
MF_UNCHECKED     // Does not place a check mark
                 // next to the item (default).
szItemName

Specifies the contents of the new menu item. Contains a null-terminated character string.

If the MF_CHANGE is specified in the wOperation field, fill these fields:
hMenu

Identifies the menu to be changed. To change an item of a pop-up menu, specify the handle that is returned from Personal Communications when the Create Menu Item function is executed. To change an item to a top-level menu bar, specify NULL.

nPosition
Specifies the menu item to be changed. The interpretation of the wPosition parameter depends on the setting of the wFlags parameter.
MF_BYPOSITION
Specifies the position of the existing menu item. The first item in the menu is at position zero.
MF_BYCOMMAND
Specifies the command ID of the existing menu item.
wIDNew

Specifies the command ID of the menu item. If an item of the top-level menu bar is changed, the handle of the menu item returned from Personal Communications when the Create Menu Item function is executed.

wFlags
The following options can be set:
MF_BYCOMMAND     // Specifies that the nPosition
                 // parameter gives the menu
                 // item control ID number.
                 // This is the default if
                 // neither MF_BYCOMMAND nor
                 // MF_BYPOSITION is set.
MF_BYPOSITION    // Specifies that the nPosition
                 // parameter gives the position
                 // of the menu item to be
                 // changed rather than an ID
                 // number.
MF_CHECKED       // Places a check mark next to
                 // the item.
MF_DISABLED      // Disables the menu item so
                 // that it cannot be selected,
                 // but does not gray it.
MF_ENABLED       // Enables the menu item so
                 // that it can be selected and
                 // restores from its grayed
                 // state.
MF_GRAYED        // Disables the menu item so
                 // that it cannot be selected,
                 // and grays it.
MF_MENUBARBREAK  // Same as MF_MENUBREAK except
                 // that for pop-up menus,
                 // separates the new column
                 // from the old column with a
                 // vertical line.
MF_MENUBREAK     // Places the item on a new
                 // line for menu bar items.
                 // For pop-up menus, places the
                 // item in a new column, with
                 // no dividing line between
                 // the columns.
MF_SEPARATOR     // Draws a horizontal dividing
                 // line.  Can only be used in
                 // a pop-up menu.  This line
                 // cannot be grayed, disabled,
                 // or highlighted.  The wIDNew
                 // and szItemName fields are
                 // ignored.
MF_UNCHECKED     // Does not place a check mark
                 // next to the item (default).
szItemName

Specifies the contents of the menu item. Contains a null-terminated character string.

If the MF_DELETE is specified in the wOperation field, fill these fields:
hMenu

Identifies the menu to be deleted. To delete an item from a pop-up menu, specify the handle that is returned from Personal Communications when the Create Menu Item, function is executed. To delete an item from a top-level menu bar, specify NULL.

nPosition
Specifies the menu item to be deleted. The interpretation of the nPosition parameter depends on the setting of the wFlags parameter.
MF_BYPOSITION
Specifies the position of the existing menu item. The first item in the menu is at position zero.
MF_BYCOMMAND
Specifies the command ID of the existing menu item.
wFlags
The following options can be set:
MF_BYCOMMAND     // Specifies that the nPosition
                 // parameter gives the menu
                 // item control ID number.
                 // This is the default if
                 // neither MF_BYCOMMAND nor
                 // MF_BYPOSITION is set.
MF_BYPOSITION    // Specifies that the nPosition
                 // parameter gives the position
                 // of the menu item to be
                 // deleted rather than an ID
                 // number.
If the MF_INSERT is specified in the wOperation field, the following fields must be filled:
hMenu

Identifies the menu to be inserted. To insert an item to a pop-up menu, specify the handle that is returned from Personal Communications when the Create Menu Item function is executed. To change an item to a top-level menu bar, specify NULL.

nPosition
Specifies the menu item before the new menu item is to be inserted. The interpretation of the nPosition parameter depends on the setting of the wFlags parameter.
MF_BYPOSITION
Specifies the position of the existing menu item. The first item in the menu is at position zero.
MF_BYCOMMAND
Specifies the command ID of the existing menu item.
wIDNew

Specifies the command ID of the menu item or, if an item of the top-level menu bar is changed, the handle of the menu item returned from Personal Communications when the Create Menu Item function is executed.

wFlags
The following options can be set:
MF_BYCOMMAND         // Specifies that the nPosition
                    // parameter gives the menu
                    // item control ID number. This
                    // is the default if neither
                    // MF_BYCOMMAND nor MF_BYPOSITION
                    // is set.
MF_BYPOSITION        // Specifies that the nPosition
                    // parameter gives the position
                    // of the menu item to be
                    // changed rather than an ID
                    // number.
MF_CHECKED           // Places a check mark next to
                    // the item.
MF_DISABLED          // Disables the menu item so
                    // that it cannot be selected,
                    // but does not gray it.
MF_ENABLED           // Enables the menu item so
                    // that it can be selected and
                    // restores from its grayed
                    // state.
MF_GRAYED            // Disables the menu item so
                    // that it cannot be selected,
                    // and grays it.
MF_MENUBARBREAK      // Same as MF_MENUBREAK except
                    // that for pop-up menus,
                    // separates the new column
                    // from the old column with a
                    // vertical line.
MF_MENUBREAK         // Places the item on a new
                    // line for menu bar items.
                    // For pop-up menus, places the
                    // item in a new column, with
                    // no dividing line between the
                    // columns.
MF_SEPARATOR         // Draws a horizontal dividing
                    // line.  Can only be used in
                    // a pop-up menu.  This line
                    // cannot be grayed, disabled,
                    // or highlighted. The wIDNew
                    // and szItemName fields are
                    // ignored.
MF_UNCHECKED         // Does not place a check mark
                    // next to the item (default).
szItemName

Specifies the contents of the menu item. Contains a null-terminated character string.

If the MF_REMOVE is specified in the wOperation field, the following fields must be filled:
hMenu

Identifies the menu to be removed. To remove an item from a pop-up menu, specify the handle that is returned from Personal Communications when the Create Menu Item function is executed. To remove an item from a top-level menu bar, specify NULL.

nPosition
Specifies the menu item to be removed. The interpretation of the nPosition parameter depends upon the setting of the wFlags parameter.
MF_BYPOSITION
Specifies the position of the existing menu item. The first item in the menu is at position zero.
MF_BYCOMMAND
Specifies the command ID of the existing menu item.
wFlags
The following options can be set:
MF_BYCOMMAND         // Specifies that the nPosition
                    // parameter gives the menu
                    // item control ID number.
                    // This is the default if
                    // neither MF_BYCOMMAND nor
                    // MF_BYPOSITION is set.
MF_BYPOSITION        // Specifies that the nPosition
                    // parameter gives the
                    // position of the menu item to
                    // be removed rather than an ID
                    // number.