guiMenuSetItem (Function)

Top  Previous  Next

Architecture:

NX32L

Device support:

NX-400

Firmware version:

1.00.00


This function sets the value of an item in the menu.

If the sub menu is supplied, then clicking the item will not trigger a menu clicked event, but instead show the sub menu, unless it would be shown outside the screen.

 

Input:

menu : SYSHANDLE

The handle to the menu to set the item on.

 

sub_menu : SYSHANDLE

A handle to a menu to use as a sub menu. If not set, the item does not have a sub menu and will cause a menu click event when clicked.

 

index : INT (1..8)

The index of the item to set.

 

title : STRING

The text to show in the item.

 

 

Returns: INT

0

- Success.

-1

- Interface is not open (see guiOpen).

-3

- Invalid handle or index.

-8

- The title contains invalid characters.

-9

- The menu is currently shown and can not be altered.

-11

- The GUI API is not supported.

 

Declaration:

FUNCTION guiMenuSetItem : INT;
VAR_INPUT
  menu     : SYSHANDLE;
  sub_menu : SYSHANDLE;
  index    : INT;
  title    : STRING;
END_VAR;

 

 

Example:

INCLUDE rtcu.inc
 
PROGRAM test;
VAR
  rc        : INT;
  menu      : SYSHANDLE;
  test_menu : SYSHANDLE;
END_VAR;
 
BEGIN
  ...
  // Create the main menu.
  rc := guiMenuCreate(menu := menu, tag := 1);
  // Create the testing menu.
  rc := guiMenuCreate(menu := test_menu, tag := 2);
  // Set the menu items.
  rc := guiMenuSetItem(menu := menu, sub_menu := test_menu, index:=1, title := "Test");
 
  rc := guiMenuSetItem(menu := test_menu, index:=1, title := "Start");
 
  rc := guiMenuSetItem(menu := test_menu, index:=2, title := "Stop");
  ...
END;
END_PROGRAM;