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); } }
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; } }
private static extern bool GetMenuItemInfo(IntPtr handle, uint uItem, bool fByPosition, ref MenuItemInfo lpmii);
private MenuElement CreateSubMenuElement(IntPtr menuHandle, MenuItemInfo info) { return new SubMenu(menuHandle, 0, info.dwTypeData, CreateMenuElements(info.hSubMenu)); }
private MenuElement CreateMenuItemElement(IntPtr menuHandle, MenuItemInfo info) { return new MenuItem(menuHandle, info.wID, info.dwTypeData); }