コード例 #1
0
 public SubMenu(string MenuText, MenuFlags Flags, NativeMenu Owner)
 {
     this.Owner    = Owner;
     this.Flags    = Flags;
     this.MenuText = MenuText;
     CreateHandle();
 }
コード例 #2
0
ファイル: Win32Helper.cs プロジェクト: kavenblog/ImageViewer
        public static void MainWindowAppendMenu(MenuFlags menuFlag, string menuTitle, Action action)
        {
            var wih = new WindowInteropHelper(Application.Current.MainWindow);
            var myHWnd = wih.Handle;

            var hMenu = GetSystemMenu(myHWnd, false);

            var uIDNewItem = (uint) _menuActionDictionary.Count + 1001;
            _menuActionDictionary.Add(uIDNewItem, action);

            AppendMenu(hMenu, menuFlag, uIDNewItem, menuTitle);

            var source = HwndSource.FromHwnd(myHWnd);
            // NOTE: hookしなおす必要があるのか分からん
            if (_hook != null)
            {
                source?.RemoveHook(_hook);
            }

            _hook = (IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled) =>
            {
                if (msg == WM_SYSCOMMAND && _menuActionDictionary.ContainsKey((uint) wParam))
                {
                    _menuActionDictionary[(uint) wParam]();
                    handled = true;
                }
                return IntPtr.Zero;
            };
            source?.AddHook(_hook);
        }
コード例 #3
0
 public MenuItem(CompositeWidget menu, string caption, Image image, MenuFlags flags)
 {
     if (menu != null && !(menu is PopupMenu) && !(menu is MenuItem))
     {
         throw new Exception("MenuItem:s can only have menus/popup and other menuitems as parent");
     }
     AttachDriverObject(menu, Guppy.Driver.CreateMenuItem(this, caption, image, flags));
 }
コード例 #4
0
        public void UnlockMenu(MenuFlags menuFlags)
        {
            MenuFlags menuStatus = GetMenuStatus();

            menuStatus ^= menuFlags;

            byte[] bytes = BitConverter.GetBytes((int)menuStatus);

            _memoryAccessor.WriteMem(ProcessName, Addresses.MenuLock.Address, bytes);
        }
コード例 #5
0
        public unsafe static void AppendMenu(MenuHandle menu, string text, int id, bool disabled = false, bool @checked = false)
        {
            MenuFlags flags = MenuFlags.String;
            if (disabled) flags |= MenuFlags.Grayed;
            if (@checked) flags |= MenuFlags.Checked;

            fixed (char* c = text)
            {
                Error.ThrowLastErrorIfFalse(
                    Imports.AppendMenuW(menu, flags, (IntPtr)id, (IntPtr)c));
            }
        }
コード例 #6
0
 public MenuItem(string MenuText, MenuFlags Flags, int ItemId = 0, MenuItem_Handler Handler = null)
 {
     this.MenuText = MenuText;
     this.Flags    = Flags;
     if (ItemId == 0)
     {
         ItemId = ("SFS" + MenuText).GetHashCode();
     }
     this.ItemInfo = new MENUITEMINFO
     {
         wID        = ItemId,
         dwTypeData = Marshal.StringToHGlobalAnsi(MenuText),
         dwItemData = new IntPtr(ItemId),
         cch        = MenuText.Length + 1,
         fState     = MenuItemInfofState.MFS_ENABLED,
         fType      = MenuItemInfofType.MFT_STRING
     };
     this.Handler = Handler;
 }
コード例 #7
0
        public unsafe static void AppendMenu(MenuHandle menu, string text, int id, bool disabled = false, bool @checked = false)
        {
            MenuFlags flags = MenuFlags.String;

            if (disabled)
            {
                flags |= MenuFlags.Grayed;
            }
            if (@checked)
                flags |= MenuFlags.Checked;

            fixed(char *c = text)
            {
                if (!Imports.AppendMenuW(menu, flags, (IntPtr)id, (IntPtr)c))
                {
                    throw Errors.GetIoExceptionForLastError();
                }
            }
        }
コード例 #8
0
        public WinFormsMenuItem(Widget shellobject, string caption, Image image, MenuFlags flags)
            : base(shellobject)
        {
            if ((flags & MenuFlags.Separator) != 0)
            {
                item     = new System.Windows.Forms.ToolStripSeparator();
                item.Tag = shellobject; //map-back from native control to guppy object

                return;                 //no events for separator
            }
            else
            {
                System.Windows.Forms.ToolStripMenuItem mi = new System.Windows.Forms.ToolStripMenuItem();
                mi.Tag = shellobject; //map-back from native control to guppy object

                item            = mi;
                mi.Image        = WinFormsDriver.ImageToWinFormsImage(image);
                mi.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None;

                //parse shortkey text
                if (caption == null)
                {
                    caption = "";
                }
                string[] capts = caption.Split('\t');
                if (capts.Length > 0)
                {
                    mi.Text = capts[0];
                }
                if (capts.Length > 1)
                {
                    mi.ShortcutKeyDisplayString = capts[1];
                }

                if ((flags & MenuFlags.Checkable) != 0)
                {
                    mi.CheckOnClick = true;
                    mi.CheckState   = (((flags & MenuFlags.Checked) != 0) ? System.Windows.Forms.CheckState.Checked : System.Windows.Forms.CheckState.Unchecked);
                }
            }

            item.Click += delegate { ((MenuItem)ShellObject).OnClicked(); };
        }
コード例 #9
0
        public MenuItem(string MenuText, Bitmap BitMap, MenuFlags Flags, int ItemId = 0, MenuItem_Handler Handler = null)
        {
            this.MenuText = MenuText;
            int MenuPictureWidth = GetSystemMetrics(71);

            this.BitMap = new Bitmap(BitMap, new Size(MenuPictureWidth, MenuPictureWidth));

            this.Flags = Flags;
            if (ItemId == 0)
            {
                ItemId = ("SFS" + MenuText).GetHashCode();
            }
            this.ItemInfo = new MENUITEMINFO
            {
                wID         = ItemId,
                dwTypeData  = Marshal.StringToHGlobalAnsi(MenuText),
                dwItemData  = new IntPtr(ItemId),
                cch         = MenuText.Length + 1,
                fState      = MenuItemInfofState.MFS_CHECKED,
                fType       = MenuItemInfofType.MFT_STRING,
                hbmpChecked = this.BitMap.GetHbitmap()
            };
            this.Handler = Handler;
        }
コード例 #10
0
 public override DriverMenuItem CreateMenuItem(Widget shellobject, string caption, Image image, MenuFlags flags)
 {
     return(new WinFormsMenuItem(shellobject, caption, image, flags));
 }
コード例 #11
0
ファイル: Driver.cs プロジェクト: ventor3000/guppy
 public abstract DriverMenuItem CreateMenuItem(Widget shellobject, string Caption, Image image, MenuFlags flags);
コード例 #12
0
 public static extern uint EnableMenuItem(IntPtr hMenu, int itemId, MenuFlags uEnable);
コード例 #13
0
ファイル: GtkSharpDriver.cs プロジェクト: ventor3000/guppy
 public override DriverMenuItem CreateMenuItem(Widget shellobject, string Caption, Image image, MenuFlags flags)
 {
     throw new NotImplementedException("menuitem not implemented in gtk driver");
 }
コード例 #14
0
 public static extern bool InsertMenu(IntPtr hMenu, int position, MenuFlags flags, IntPtr uIDNewItem, [MarshalAs(UnmanagedType.LPTStr)] string lpNewItem);
コード例 #15
0
 public static extern bool InsertMenu(IntPtr hMenu, Int32 wPosition, MenuFlags wFlags, Int32 wIDNewItem, string lpNewItem);
コード例 #16
0
 private static extern bool AppendMenu(IntPtr hMenu, MenuFlags uFlags, IntPtr uIDNewItem, string lpNewItem);
コード例 #17
0
ファイル: User32.cs プロジェクト: lurume84/jirafy-toastify
 public static extern bool EnableMenuItem(IntPtr hMenu, uint uIDEnableItem, MenuFlags uEnable);
コード例 #18
0
 private static extern bool RemoveMenu(IntPtr hMenu, uint uPosition, MenuFlags uFlags);
コード例 #19
0
 public static extern bool DeleteMenu(IntPtr hMenu, int uPosition, MenuFlags uFlags);
コード例 #20
0
 private static extern long InsertMenu(IntPtr hMenu, int nPosition, MenuFlags wFlags, int wIDNewItem, [MarshalAs(UnmanagedType.VBByRefStr)] ref string lpNewItem);
コード例 #21
0
ファイル: Form1.cs プロジェクト: Annushka34/WinForm
 private static extern int RemoveMenu(IntPtr hMenu,
                                      int Position, MenuFlags uFlags);
コード例 #22
0
 public static extern bool RemoveMenu(IntPtr hMenu, UInt32 uPosition, MenuFlags uFlags);
コード例 #23
0
 public static extern bool InsertMenu(
     IntPtr hmenu,
     uint position,
     MenuFlags flags,
     uint item_id,
     [MarshalAs(UnmanagedType.LPTStr)]string item_text);
コード例 #24
0
 private static extern bool AppendMenu(IntPtr hMenu, MenuFlags uFlags,
                                       uint wIDNewItem, String lpNewItem);
コード例 #25
0
 public static extern bool EnableMenuItem([In] IntPtr hMenu, [In, MarshalAs(UnmanagedType.U4)] SystemMenuCommands uIDEnableItem, [In, MarshalAs(UnmanagedType.U4)] MenuFlags uEnable);
コード例 #26
0
 private static extern bool InsertMenu(IntPtr hMenu, uint uPosition, MenuFlags uFlags, uint uIDNewItem, string lpNewItem);
コード例 #27
0
ファイル: NativeMethods.cs プロジェクト: bewbaloo/SlackUI
 internal static extern bool AppendMenu(IntPtr hMenu, MenuFlags uFlags, UIntPtr uIDNewItem, string lpNewItem);
コード例 #28
0
 private static extern bool SetMenuItemBitmaps(IntPtr hMenu, uint uPosition, MenuFlags uFlags, IntPtr hBitmapUnchecked, IntPtr hBitmapChecked);
コード例 #29
0
ファイル: PInvoke.cs プロジェクト: gusper/Journaley
 public static extern bool EnableMenuItem(IntPtr hMenu, SystemCommands uIDEnableItem, MenuFlags uEnable);
コード例 #30
0
ファイル: User32.cs プロジェクト: lurume84/jirafy-toastify
 public static extern bool EnableMenuItem(IntPtr hMenu, SysCommands uIDEnableItem, MenuFlags uEnable);
コード例 #31
0
 internal static extern bool InsertMenu(IntPtr hmenu, uint position, MenuFlags flags,
                                        uint item_id, [MarshalAs(UnmanagedType.LPTStr)] string item_text);
コード例 #32
0
 static extern bool AppendMenu(IntPtr hMenu, MenuFlags uFlags, uint uIDNewItem, string lpNewItem);
コード例 #33
0
ファイル: SystemMenuAPI.cs プロジェクト: rafntor/bdhero
 public static extern bool AppendMenu(IntPtr hMenu, [MarshalAs(UnmanagedType.U4)] MenuFlags uFlags, uint uIDNewItem, string lpNewItem);
コード例 #34
0
 public static extern bool AppendMenu(IntPtr hMenu, MenuFlags uFlags, uint uIDNewItem, string lpNewItem);
コード例 #35
0
ファイル: SystemMenuAPI.cs プロジェクト: rafntor/bdhero
 public static extern bool InsertMenu(IntPtr hMenu, uint uPosition, [MarshalAs(UnmanagedType.U4)] MenuFlags uFlags, uint uIDNewItem, string lpNewItem);
コード例 #36
0
ファイル: Native.cs プロジェクト: vserrago/Borderless-Gaming
 public static extern bool RemoveMenu(IntPtr hMenu, uint uPosition, MenuFlags uFlags);
コード例 #37
0
 public static extern bool AppendMenu(IntPtr hMenu, MenuFlags uFlags, IntPtr MenuBitMAp, [MarshalAs(UnmanagedType.LPTStr)] string lpNewItem);