Esempio n. 1
0
            // Also needed for SetFocus Keyboard navigation
            private static bool IsSeparator (IntPtr hmenu, int position)
            {
                NativeMethods.MENUITEMINFO menuItemInfo = new NativeMethods.MENUITEMINFO ();
                menuItemInfo.cbSize = Marshal.SizeOf (menuItemInfo.GetType ());
                menuItemInfo.fMask = NativeMethods.MIIM_FTYPE | NativeMethods.MIIM_SUBMENU | NativeMethods.MIIM_STATE;

                if (!Misc.GetMenuItemInfo(hmenu, position, true, ref menuItemInfo))
                {
                    return false;
                }

                return (Misc.IsBitSet(menuItemInfo.fType, NativeMethods.MF_SEPARATOR) ||
                        Misc.IsBitSet(menuItemInfo.fType, NativeMethods.MF_MENUBARBREAK) ||
                        Misc.IsBitSet(menuItemInfo.fType, NativeMethods.MF_MENUBREAK));
            }
Esempio n. 2
0
            // Retrieve type of menu item
            private MenuItemType GetMenuItemType ()
            {
                if (_menuType == WindowsMenu.MenuType.System)
                {
                    return MenuItemType.SubMenu;
                }

                NativeMethods.MENUITEMINFO menuItemInfo = new NativeMethods.MENUITEMINFO();
                menuItemInfo.cbSize = Marshal.SizeOf(menuItemInfo.GetType());
                menuItemInfo.fMask = NativeMethods.MIIM_FTYPE | NativeMethods.MIIM_SUBMENU | NativeMethods.MIIM_STATE;

                if (Misc.GetMenuItemInfo(_hmenu, _item, true, ref menuItemInfo))
                {
                    if (menuItemInfo.hSubMenu != IntPtr.Zero)
                    {
                        return MenuItemType.SubMenu;
                    }

                    if (Misc.IsBitSet(menuItemInfo.fType, NativeMethods.MF_SEPARATOR) ||
                        Misc.IsBitSet(menuItemInfo.fType, NativeMethods.MF_MENUBARBREAK) ||
                        Misc.IsBitSet(menuItemInfo.fType, NativeMethods.MF_MENUBREAK))
                    {
                        return MenuItemType.Spacer;
                    }
                }

                return MenuItemType.Command; // Everything else
            }
Esempio n. 3
0
            private bool IsRadioCheck()
            {
                NativeMethods.MENUITEMINFO menuItemInfo = new NativeMethods.MENUITEMINFO();
                menuItemInfo.cbSize = Marshal.SizeOf(menuItemInfo.GetType());
                menuItemInfo.fMask = NativeMethods.MIIM_FTYPE | NativeMethods.MIIM_SUBMENU | NativeMethods.MIIM_STATE;

                if (!Misc.GetMenuItemInfo(_hmenu, _item, true, ref menuItemInfo))
                {
                    return false;
                }

                return (Misc.IsBitSet(menuItemInfo.fType, NativeMethods.MFT_RADIOCHECK) && menuItemInfo.hbmpChecked == IntPtr.Zero);
            }