FormSystemMenuDemo.cs
上传用户:dzysfj
上传日期:2021-09-14
资源大小:118k
文件大小:2k
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Text;
- using System.Windows.Forms;
- using CSharpWin;
- using System.Diagnostics;
- namespace SystemMenuDemo
- {
- public partial class FormSystemMenuDemo : Form
- {
- private SystemMenuNativeWindow _systemMenuNativeWindow;
- public FormSystemMenuDemo()
- {
- InitializeComponent();
- linkLabel1.Click += delegate(object sender, EventArgs e)
- {
- Process.Start("www.csharpwin.com");
- };
- }
- protected override void OnCreateControl()
- {
- base.OnCreateControl();
- if (_systemMenuNativeWindow == null)
- {
- _systemMenuNativeWindow = new SystemMenuNativeWindow(this);
- }
- _systemMenuNativeWindow.InertSeparator(7);
- _systemMenuNativeWindow.InsertMenu(
- 8,
- 1001,
- "访问 www.csharpwin.com",
- delegate(object sender,EventArgs e)
- {
- Process.Start("www.csharpwin.com");
- });
- _systemMenuNativeWindow.AppendSeparator();
- _systemMenuNativeWindow.AppendMenu(
- 1000,
- "关于...(&A)",
- delegate(object sender, EventArgs e)
- {
- AboutBox about = new AboutBox();
- about.ShowDialog();
- });
- }
- protected override void OnHandleDestroyed(EventArgs e)
- {
- base.OnHandleDestroyed(e);
- if (_systemMenuNativeWindow != null)
- {
- _systemMenuNativeWindow.Dispose();
- _systemMenuNativeWindow = null;
- }
- }
- private void button1_Click(object sender, EventArgs e)
- {
- _systemMenuNativeWindow.Revert();
- }
- }
- }