本文介绍了在窗体最小化时检测按键。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个Windows窗体按键应用程序。我正在使用F3,F4,F5按键进行某些操作。但是当表单最小化时,按键不起作用。它应该在表单最小化时工作。如何在C#中解决这个问题。



I created one windows form keypress application.And I am using F3,F4,F5 keypress for some operation. But keypress is not working while form is minimised. It should work when form is minimised.How to fix this problem in C#.

protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
       {
               this.WindowState = FormWindowState.Minimized;

               oWord.Visible = true;
               if (keyData == Keys.F3)
               {
                   this.WindowState = FormWindowState.Minimized;
                   CaptureWithTaskBar();
                   this.WindowState = FormWindowState.Normal;
               }
               else if (keyData == Keys.F4)
               {
                   this.WindowState = FormWindowState.Minimized;
                   CaptureWithoutTaskBar();
                   this.WindowState = FormWindowState.Normal;
               }
               else if (keyData == Keys.F5)
               {
                   SaveDocument();
               }
}

推荐答案


这篇关于在窗体最小化时检测按键。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 05:12