예제 #1
0
 /// <summary>
 /// 添加菜单项并返回其ID
 /// </summary>
 /// <param name="hMenu">要操作的菜单句柄</param>
 /// <param name="text">菜单项文本。当文本为"-"时,会视为分隔条;当文本指定为<see cref="string.Empty"/>时,为避免可能引起的其它项的快捷键不可用的问题,会将文本更改为一个空格</param>
 /// <param name="onClick">点击事件处理程序</param>
 /// <param name="subMenu">子菜单。赋值此参数将使<paramref name="onClick"/>参数失效,即不会触发点击事件</param>
 /// <param name="beforeItem">要插在哪个标准项的前边</param>
 /// <param name="isChecked">是否勾选。注意项的勾选状态并不会因点击自动切换,需自行响应<paramref name="onClick"/>事件并用<see cref="SetItemChecked(IntPtr, int, bool, bool)"/>处理</param>
 /// <param name="enabled">是否可用</param>
 /// <exception cref="Win32Exception" />
 public static int AddItem(IntPtr hMenu, string text, EventHandler <SystemMenuItemEventArgs> onClick, ContextMenu subMenu, SystemMenuStandardItem beforeItem, bool isChecked = false, bool enabled = true) =>
 AddItem(hMenu, text, onClick, subMenu, (int)beforeItem, false, isChecked, enabled);
예제 #2
0
 /// <summary>
 /// 添加分隔条并返回其ID
 /// </summary>
 /// <exception cref="Win32Exception" />
 public static int AddSeparator(IntPtr hMenu, SystemMenuStandardItem beforeItem) =>
 AddSeparator(hMenu, (int)beforeItem, false);
예제 #3
0
 /// <summary>
 /// 添加展开项(能展开子菜单的项)并返回其ID
 /// </summary>
 /// <exception cref="Win32Exception" />
 public static int AddDropDown(IntPtr hMenu, string text, ContextMenu subMenu, SystemMenuStandardItem beforeItem) =>
 AddDropDown(hMenu, text, subMenu, (int)beforeItem, false);
예제 #4
0
 /// <summary>
 /// 删除菜单项。对于展开项,本方法并不会连带销毁子菜单
 /// <para>【注意】删除标准项后窗体将失去对应能力</para>
 /// </summary>
 /// <exception cref="Win32Exception" />
 public static void RemoveItem(IntPtr hMenu, SystemMenuStandardItem item) => RemoveItem(hMenu, (int)item, false);