Exemplo n.º 1
0
        internal IEnumerable<MenuElement> CreateMenuElements(IntPtr menuHandle)
        {
            var itemsCount = GetMenuItemCount(menuHandle);

            if (itemsCount != -1)
                for (uint i = 0; i < itemsCount; i++)
                {
                    var id = GetMenuItemID(menuHandle, i);

                    var menuItemInfo = new MenuItemInfo
                    {
                        cbSize = MenuItemInfo.SizeOf,
                        fMask = Masks.MiimId | Masks.MiimString | Masks.MiimSubmenu,
                        dwTypeData = new string(' ', 100),
                        cch = 100
                    };

                    var result = GetMenuItemInfo(menuHandle, i, true, ref menuItemInfo);

                    if (result)
                        yield return id == -1
                                     	? CreateSubMenuElement(menuHandle, menuItemInfo)
                                     	: CreateMenuItemElement(menuHandle, menuItemInfo);
                }
        }
Exemplo n.º 2
0
        public IEnumerable<string> GetMenuInfos()
        {
            var itemsCount = GetMenuItemCount();

            if (itemsCount != -1)
                for (uint i = 0; i < itemsCount; i++)
                {
                    var menuItemInfo = new MenuItemInfo
                                       	{
                                       		cbSize = MenuItemInfo.SizeOf,
                                       		fMask = Masks.MiimId | Masks.MiimString,
                                       		dwTypeData = new string(' ', 100),
                                       		cch = 100
                                       	};

                    var result = GetMenuItemInfo(Handle, i, true, ref menuItemInfo);

                    if (result)
                        yield return menuItemInfo.dwTypeData;
                }
        }
Exemplo n.º 3
0
 private static extern bool GetMenuItemInfo(IntPtr handle, uint uItem, bool fByPosition, ref MenuItemInfo lpmii);
Exemplo n.º 4
0
 private MenuElement CreateSubMenuElement(IntPtr menuHandle, MenuItemInfo info)
 {
     return new SubMenu(menuHandle, 0, info.dwTypeData, CreateMenuElements(info.hSubMenu));
 }
Exemplo n.º 5
0
 private MenuElement CreateMenuItemElement(IntPtr menuHandle, MenuItemInfo info)
 {
     return new MenuItem(menuHandle, info.wID, info.dwTypeData);
 }