0

CtrlAlt如果在单击鼠标左键时按下,我想检查我的表单 。有什么方法可以检查吗?

4

2 回答 2

8
void window_MouseLeftButtonDown_1(object sender, MouseEventArgs e)
{
    if (Control.ModifierKeys == Keys.Control && Control.ModifierKeys == Keys.Alt)
    {
        //...
    }
}
于 2013-01-06T08:42:18.760 回答
7

WPF:在 xaml 中将事件添加到您的窗口:

MouseLeftButtonDown="window_MouseLeftButtonDown_1"

或在后面的代码中:

public MainWindow()
{
   InitializeComponent();

   this.MouseLeftButtonDown += window_MouseLeftButtonDown_1;
}

然后您可以检查回调中的按键

private void window_MouseLeftButtonDown_1(object sender, MouseButtonEventArgs e)
{
   if (Keyboard.IsKeyDown(Key.LeftCtrl) && Keyboard.IsKeyDown(Key.LeftAlt))
   {
      // ...
   }
}
于 2013-01-06T02:58:10.910 回答