简体   繁体   中英

How to handle Ctrl + Break or Ctrl + Pause in windows application

My requirement is when ever user pressed Ctrl+Pause in my windows application I want to show some message to user. How to capture Ctrl+Pause in the windows form using Keydown event.

The event handler would look something like this:

void myForm_KeyDown(object sender, KeyEventArgs e)
{
    if(e.KeyCode == Keys.Pause && ModifierKeys == Keys.Control)
    {
      //Code for showing message goes here
    }
}

Ctrl+Pause generate special KeyCode: Cancel

void myForm_KeyDown(object sender, KeyEventArgs e)
{
  if(e.KeyCode == Keys.Cancel) //Control + Pause
  {
    //Code for showing message goes here
  }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM