/// <summary> /// Adds a menu item to the form's system menu. /// </summary> /// <param name="title">The title of the menu to be displayed (or <c>null</c>).</param> /// <param name="key">An application defined key to be used to identify the item when selected.</param> /// <remarks> /// <para> /// Pass <paramref name="title" /> as <c>null</c> to append a menu separator instead of a menu item. /// </para> /// <note> /// This works only for top-level forms. The application can /// handle menu clicks by listening on the <see cref="SysMenuClick" /> event. /// </note> /// </remarks> public void AddSysMenu(string title, string key) { var hSysMenu = WinApi.GetSystemMenu(this.Handle, false); if (title == null) { WinApi.AppendMenu(hSysMenu, MenuFlags.MF_SEPARATOR, 0, string.Empty); return; } WinApi.AppendMenu(hSysMenu, MenuFlags.MF_STRING, nextSysMenuID, title); sysMenuMap.Add(nextSysMenuID, key); nextSysMenuID++; }