09-15-2008 03:17 AM
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
09-16-2008 01:06 PM
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.
09-17-2008 03:15 AM
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
09-17-2008 04:22 AM
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
09-18-2008 06:43 PM
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);
}
09-18-2008 10:40 PM
Hi Nestor_G,
That was of great help. It worrked fine. Thanks a lot.
Regards
Sgy