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,
             MAKELONG(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 unused:13;     // ** unused **
 unsigned fRelease:1;    // Session frees memory
 unsigned freserved:2;   // ** reserved **
 int      cfFormat;      // Always CF_DSPTEXT
 HANDLE   hMenu;         // Handle of the menu item
 WORD     wPosition;     // The position of the menu
                         // item
 WORD     wIDNew;        // The menu ID of the new
                         // menu item
 WORD     wOperation;    // Specifies the operation
 WORD     wFlags;        // Specifies the options
 unsigned char szItemName[1]; // String of the item
} CHANGEMENU, FAR *lpCHANGEMENU;
The following operations are supported:
MF_APPEND  // Appends a menu item to the end of a menu.
MF_CHANGE  // Modifies a menu item in a menu.
MF_DELETE  // Deletes a menu item from a menu, destroying
           // the menu item.
MF_INSERT  // Inserts a menu item into a menu.
MF_REMOVE  // Removes a menu item from a menu but does not
           // destroy the menu item.
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 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 content 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 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 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 content 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 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 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 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 content 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 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.