/// <summary> /// 窗体接收到的按键点击事件 /// 处理方向键事件,移动选框位置 /// </summary> private void CaptureForm_KeyDown(object sender, KeyEventArgs e) { if (e.KeyValue >= 37 && e.KeyValue <= 40 && !txtDrawText.Visible) { Rectangle rect = imageProcessBox.SelectedRect; rect.Width -= 1; rect.Height -= 1; switch (e.KeyData) { case Keys.Left: if (rect.X > 0) { rect.X -= 1; Win32.SetCursorPos(MousePosition.X - 1, MousePosition.Y); } break; case Keys.Up: if (rect.Y > 0) { rect.Y -= 1; Win32.SetCursorPos(MousePosition.X, MousePosition.Y - 1); } break; case Keys.Right: if (rect.Right < this.Width) { rect.X += 1; Win32.SetCursorPos(MousePosition.X + 1, MousePosition.Y); } break; case Keys.Down: if (rect.Bottom < this.Height) { rect.Y += 1; Win32.SetCursorPos(MousePosition.X, MousePosition.Y + 1); } break; } imageProcessBox.SelectedRect = rect; SetToolBarLocation(); this.Refresh(); } switch (e.KeyData) { case Keys.Control | Keys.S: btnSave_Click(sender, e); break; case Keys.Control | Keys.Z: btnReset_Click(sender, e); break; case Keys.Escape: this.Close(); break; } //base.OnKeyDown(e); }