给窗体的任务栏右键菜单增加项目
        [DllImport("user32.dll")]
        private static extern int GetSystemMenu(int hwnd, int bRevert);
        [DllImport("user32.dll")]
        private static extern int AppendMenu(int hMenu, int Flagsw, int IDNewItem, string lpNewItem);
            //   get   handle   to   system   menu  
            int menu = GetSystemMenu(this.Handle.ToInt32(), 0);
            //   add   a   separator  
            AppendMenu(menu, 0xA00, 0, null);
            //   add   an   item   with   a   unique   ID  
            AppendMenu(menu, 0, 1234, "跳至URL");
            AppendMenu(menu, 0, 1235, "关于HTML帮助");

处理事件
        protected override void WndProc(ref Message m)
        {
            base.WndProc(ref   m);
            //   WM_SYSCOMMAND   is   0x112  
            if (m.Msg == 0x112)
            {
                //   check   for   my   new   menu   item   ID  
                if (m.WParam.ToInt32() == 1234)
                {
                    //   show   About   box   here  
                    MessageBox.Show("Btn One");
                }
                if (m.WParam.ToInt32() == 1235)
                {
                    //   show   About   box   here  
                    MessageBox.Show("Btn Two");
                }
            }
        }

相关文章:

  • 2022-12-23
  • 2022-02-11
  • 2022-12-23
  • 2022-12-23
  • 2021-08-25
  • 2022-12-23
  • 2021-03-31
  • 2021-06-04
猜你喜欢
  • 2021-10-31
  • 2021-06-26
  • 2021-04-14
  • 2021-06-12
  • 2021-11-29
  • 2022-01-16
  • 2022-12-23
相关资源
相似解决方案