示例#1
0
        private void InitSystemMenu()
        {
            var systemMenu = new SystemMenu(this, this);

            var resizeMenuItem = systemMenu.CreateMenuItem("&Resize...");

            resizeMenuItem.Clicked += delegate
            {
                new FormResizeWindow(this).ShowDialog(this);
            };

            var alwaysOnTopMenuItem = systemMenu.CreateMenuItem("Always on &top");

            alwaysOnTopMenuItem.Clicked += delegate
            {
                var alwaysOnTop = !alwaysOnTopMenuItem.Checked;
                TopMost = alwaysOnTop;
                alwaysOnTopMenuItem.Checked = alwaysOnTop;
                systemMenu.UpdateMenu(alwaysOnTopMenuItem);
            };

            uint pos = 5;

            systemMenu.InsertSeparator(pos++);
            systemMenu.InsertMenu(pos++, resizeMenuItem);
            systemMenu.InsertMenu(pos++, alwaysOnTopMenuItem);
        }
示例#2
0
 private void frmMain_Load(object sender, System.EventArgs e)
 {
     try
     {
         m_SystemMenu = SystemMenu.FromForm(this);
         // Add a separator ...
         m_SystemMenu.AppendSeparator();
         // ... and an "About" entry
         m_SystemMenu.AppendMenu(m_AboutID, "About this...");
         // And a "Reset" item on top
         m_SystemMenu.InsertSeparator(0);
         m_SystemMenu.InsertMenu(0, m_ResetID, "Reset Systemmenu");
     }
     catch (NoSystemMenuException /* err */)
     {
         // Do some error handling
     }
 }