private const int WMS= 0x007B;
protected override void WndProc(ref Message m)
{
if (m.Msg == WMS)
{
try
{
ContextMenu contextMenu = new ContextMenu();
MenuItem clearUndo = new MenuItem();
clearUndo.Text = "撤销(&U)";
clearUndo.Click += new System.EventHandler(this.clearUndo_Click);
contextMenu.MenuItems.Add(clearUndo);
this.ContextMenu = contextMenu;
contextMenu.Tag = this;
this.ContextMenu = contextMenu;
Point point = new Point(MousePosition.X, MousePosition.Y);
ContextMenu.Show(this, point);
}
catch (System.Exception ex)
{ }
}
if (m.Msg == WMS)
{
return;
}
base.WndProc(ref m);
}
private void clearUndo_Click(object sender, System.EventArgs e)
{
this.Undo();
}