NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

GetRunTimeToolMenuItems editArgsParam

Hi!

How to use GetRunTimeToolMenuItems for getting tools menu items ar run time. What should be the value of editArgsParam which is the input parameter for GetRunTimeToolMenuItems func.

 

Thanks & Regards

Sgy 

0 Kudos
Message 1 of 6
(2,959 Views)

Hi Sgy1,

 

Note that the first parameter in GetRunTimeToolMenuItems() is optional. If you are using this function within TestStand, you may simply type the keyword, Nothing, as the first parameter. For example, the following API call in TestStand 4.x will return the fourth, enabled menu item in my Tools Menu.

 

RunState.Engine.GetRunTimeToolMenuItems(Nothing,0).Item(4).Text

 

If you would like to use the editArgsParam option, please read the topic EditArgs in the TestStand Help.

Nestor
0 Kudos
Message 2 of 6
(2,936 Views)

Hi!

Eventough editArgs is optional, while calling this API from C# gives the following compile error 

'No overload for method 'GetRunTimeToolMenuItems' takes '0' arguments'

So I tried giving editArgs as given below.

EditArgs editArgsObj = tsEngine.NewEditArgs(); 

RunTimeMenuItems items = tsEngine.GetRunTimeToolMenuItems(editArgsObj, 0) ;

Then value of  ItemEnabled   of each item will always be false.

Is this  because of  editArgsObj. How should we modify editArgsObj.

 

Thanks & Regards

Sgy 

0 Kudos
Message 3 of 6
(2,923 Views)

Hi!

I would like to add one more point. 

My main purpose is to get the enabled state of each menu item in Tools menu.

It would be very helpful if someone could help on this.

 

Thanks.

 

Sgy 

0 Kudos
Message 4 of 6
(2,919 Views)

Hi Sgy,

 

Note that in the TestStand API Help for EditArgs, omitting optional arguments in C# is done by using the string, System.Type.Missing, as the argument.

The following C# code snippet will iterate through a collection of Menu Items, and display the names of enabled items.

 

Hope this helps Sgy.

 

 

RunTimeMenuItems    m_Items;
RunTimeMenuItem     m_Item;
           
// Get a collection of Menu Items
m_Items = this.axApplicationMgr.GetEngine().GetRunTimeToolMenuItems(System.Type.Missing, 0);

 

// Scan all the menu items

for (int i = 0; i < m_Items.Count; i++)
{
   m_Item = m_Items[i]; // get an item
   if (m_Item.ItemEnabled)
      MessageBox.Show(m_Item.Text);
}

Nestor
0 Kudos
Message 5 of 6
(2,886 Views)

Hi Nestor_G,

 That was of great help. It worrked fine. Thanks a lot.

 

Regards

Sgy 

0 Kudos
Message 6 of 6
(2,882 Views)