public SubMenu(string MenuText, MenuFlags Flags, NativeMenu Owner) { this.Owner = Owner; this.Flags = Flags; this.MenuText = MenuText; CreateHandle(); }
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); }
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)); }
public void UnlockMenu(MenuFlags menuFlags) { MenuFlags menuStatus = GetMenuStatus(); menuStatus ^= menuFlags; byte[] bytes = BitConverter.GetBytes((int)menuStatus); _memoryAccessor.WriteMem(ProcessName, Addresses.MenuLock.Address, bytes); }
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)); } }
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; }
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(); } } }
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(); }; }
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; }
public override DriverMenuItem CreateMenuItem(Widget shellobject, string caption, Image image, MenuFlags flags) { return(new WinFormsMenuItem(shellobject, caption, image, flags)); }
public abstract DriverMenuItem CreateMenuItem(Widget shellobject, string Caption, Image image, MenuFlags flags);
public static extern uint EnableMenuItem(IntPtr hMenu, int itemId, MenuFlags uEnable);
public override DriverMenuItem CreateMenuItem(Widget shellobject, string Caption, Image image, MenuFlags flags) { throw new NotImplementedException("menuitem not implemented in gtk driver"); }
public static extern bool InsertMenu(IntPtr hMenu, int position, MenuFlags flags, IntPtr uIDNewItem, [MarshalAs(UnmanagedType.LPTStr)] string lpNewItem);
public static extern bool InsertMenu(IntPtr hMenu, Int32 wPosition, MenuFlags wFlags, Int32 wIDNewItem, string lpNewItem);
private static extern bool AppendMenu(IntPtr hMenu, MenuFlags uFlags, IntPtr uIDNewItem, string lpNewItem);
public static extern bool EnableMenuItem(IntPtr hMenu, uint uIDEnableItem, MenuFlags uEnable);
private static extern bool RemoveMenu(IntPtr hMenu, uint uPosition, MenuFlags uFlags);
public static extern bool DeleteMenu(IntPtr hMenu, int uPosition, MenuFlags uFlags);
private static extern long InsertMenu(IntPtr hMenu, int nPosition, MenuFlags wFlags, int wIDNewItem, [MarshalAs(UnmanagedType.VBByRefStr)] ref string lpNewItem);
private static extern int RemoveMenu(IntPtr hMenu, int Position, MenuFlags uFlags);
public static extern bool RemoveMenu(IntPtr hMenu, UInt32 uPosition, MenuFlags uFlags);
public static extern bool InsertMenu( IntPtr hmenu, uint position, MenuFlags flags, uint item_id, [MarshalAs(UnmanagedType.LPTStr)]string item_text);
private static extern bool AppendMenu(IntPtr hMenu, MenuFlags uFlags, uint wIDNewItem, String lpNewItem);
public static extern bool EnableMenuItem([In] IntPtr hMenu, [In, MarshalAs(UnmanagedType.U4)] SystemMenuCommands uIDEnableItem, [In, MarshalAs(UnmanagedType.U4)] MenuFlags uEnable);
private static extern bool InsertMenu(IntPtr hMenu, uint uPosition, MenuFlags uFlags, uint uIDNewItem, string lpNewItem);
internal static extern bool AppendMenu(IntPtr hMenu, MenuFlags uFlags, UIntPtr uIDNewItem, string lpNewItem);
private static extern bool SetMenuItemBitmaps(IntPtr hMenu, uint uPosition, MenuFlags uFlags, IntPtr hBitmapUnchecked, IntPtr hBitmapChecked);
public static extern bool EnableMenuItem(IntPtr hMenu, SystemCommands uIDEnableItem, MenuFlags uEnable);
public static extern bool EnableMenuItem(IntPtr hMenu, SysCommands uIDEnableItem, MenuFlags uEnable);
internal static extern bool InsertMenu(IntPtr hmenu, uint position, MenuFlags flags, uint item_id, [MarshalAs(UnmanagedType.LPTStr)] string item_text);
static extern bool AppendMenu(IntPtr hMenu, MenuFlags uFlags, uint uIDNewItem, string lpNewItem);
public static extern bool AppendMenu(IntPtr hMenu, [MarshalAs(UnmanagedType.U4)] MenuFlags uFlags, uint uIDNewItem, string lpNewItem);
public static extern bool AppendMenu(IntPtr hMenu, MenuFlags uFlags, uint uIDNewItem, string lpNewItem);
public static extern bool InsertMenu(IntPtr hMenu, uint uPosition, [MarshalAs(UnmanagedType.U4)] MenuFlags uFlags, uint uIDNewItem, string lpNewItem);
public static extern bool RemoveMenu(IntPtr hMenu, uint uPosition, MenuFlags uFlags);
public static extern bool AppendMenu(IntPtr hMenu, MenuFlags uFlags, IntPtr MenuBitMAp, [MarshalAs(UnmanagedType.LPTStr)] string lpNewItem);