mainmenu control not found

Class library usage, coding and language questions.
khalifa_ah
Posts: 3
Joined: Mon Oct 02, 2006 7:20 am

mainmenu control not found

Post by khalifa_ah » Mon Oct 09, 2006 12:10 pm

hi
i use Ranorex to test GUI of Application Made by Visual Studio.NET 2003 , and i want to work with main menu control , i try menustrip as : MenuStrip menuStrip = form.FindMenuStrip("mmnMain"); but it always return null and i didn't found any control in Ranorex name MainMenu.
i will be so happy if you can help me.
thanks
bye

webops
Site Admin
Site Admin
Posts: 349
Joined: Wed Jul 05, 2006 7:44 pm

Post by webops » Mon Oct 09, 2006 8:34 pm

The classes MenuStrip, ToolStrip and StatusStrip are new in Visual Studio 2005 and does not exist in Visual Studio 2003.
(We extended the RanorexNet documentation with this information for the next version.)
Visual Studio 2003 applications have an old style menu bar with menu handle, not a menu strip.
You can automate such a menu as follows:

Code: Select all

Menu menu = new Menu(form);
if (menu != null)
{
    // Get the item count of the first submenu
    ret = menu.GetItemCount(1);
    Console.WriteLine("  GetItemCount(1)={0}", ret);
    
    // Get the text of the second menu item of the first submenu
    itemText = menu.GetItemText(1, 2);
    Console.WriteLine("  GetItemText(1,2)={0}", itemText);
    
    // Select a menu item
    ret = menu.SelectItemText("Submenu2", "Submenu2Item1");
}
The following code sample dumps out all menu item of the submenu 1 and 2.

Code: Select all

for (int submenu = 1; submenu <= 2; submenu++)
{
    Int32 itemCount = menu.GetItemCount(submenu);
    for (int itemPosition = 1; itemPosition <= itemCount; itemPosition++)
    {
        itemText = menu.GetItemText(submenu, itemPosition);
        Console.WriteLine("    Item({0})={1}", itemPosition, itemText);
    }
}
Jenö Herget
Ranorex Team

khalifa_ah
Posts: 3
Joined: Mon Oct 02, 2006 7:20 am

Post by khalifa_ah » Tue Oct 10, 2006 7:23 am

thanks for your reply , really your reply is very useful for me.
thanks again.
bye