Menus of the Windows Explorer in Vista

Class library usage, coding and language questions.
p.zott
Posts: 18
Joined: Sat Jul 22, 2006 6:35 pm

Menus of the Windows Explorer in Vista

Post by p.zott » Thu Nov 15, 2007 11:15 pm

I try to use the menus of the Windows Explorer in Vista but it does not work with the Menu class.
Can somebody suggest me an other way.

Peter

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Post by Support Team » Mon Nov 19, 2007 12:30 am

The Menu of the Windows Explorer in Vista is a ToolBar and not a Menu control.
It has no Text and no ControlId so it's difficult to find.
Use the following code to automate the menus of the explorer:

Code: Select all

Form form = Application.FindFormClassName("CabinetWClass");
form.Activate();

ToolBar toolbar = null;
// Find the toolbar with the commandId = 32896 (View menu item)
foreach (Control control in form.Controls)
{
    if (control.ClassName == "ToolbarWindow32")
    {
        toolbar = new ToolBar(control.Handle);
        if (toolbar.GetItemIndex(32896) > 0)
            break;
        else
            toolbar = null;
    }
}

if (toolbar != null)
{
    toolbar.ClickItem(32896); // Click the View menu item
    Application.PopupMenuSelectItem("Details");
}
Jenö
Ranorex Support Team

p.zott
Posts: 18
Joined: Sat Jul 22, 2006 6:35 pm

Post by p.zott » Wed Dec 05, 2007 12:22 am

Thank you, this works fine.

Peter