调用封闭表格的快捷键 [英] Shortcut keys for invoking a closed form

查看:76
本文介绍了调用封闭表格的快捷键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我正在创建一个桌面应用程序,该应用程序将在特定时间间隔后调用一个弹出式窗体.我想添加一项功能,如果按下快捷键,该窗体将弹出... plz帮助.

Hi,
I am creating a desktop application which invokes a pop up form after a specific time interval.I want to add a functionality that if a shortcut key is pressed the form should pop up...plz help.

推荐答案

如果您希望窗体本身拦截快捷键,则在窗体上的任何控件获取键事件(Pressed,Down,Up)之前,请:设置窗体的KeyPreview属性.将Form设置为"true",并编写适当的表单键事件处理程序,如果您选择的键组合和修饰符(shift,alt,control)处于活动状态,则可以在其中显示弹出窗口.

您的问题暗示正在使用计时器;我不清楚计时器是否独立于所接收的快捷键而运行,但是您可以通过使用计时器来控制所接收的快捷方式与弹出窗口的显示之间的延迟.意思.

请注意关闭表单或UserControl会破坏该Form或UserControl的实例,与"隐藏一个Form或UserControl不会破坏该实例,并允许您通过' '显示方法.

我的猜测是,您正在描述一种情况,您确实想使用隐藏"而不是关闭":即,您不想每次都重新创建弹出实例(通过" new或Activator.CreateInstance")需要的时间.
If you want the Form itself to intercept a shortcut key, before any of the Controls on the Form get the Key Event (Pressed, Down, Up), then: set the the KeyPreview Property of the Form to ''true, and write the appropriate form key-event handler in which, if your choice of key-combinations and modifiers (shift, alt, control) is active, you ''Show your pop-up.

Your question implies a Timer being used; I''m not clear if the Timer is something operating independently of the shortcut-key being received, but you can control the delay between shortcut received and appearance of the pop-up, by using a Timer, if that''s what you mean.

Note the distinction between ''closing a Form, or UserControl, which destroys the instance of that Form or UserControl, and ''hiding a Form or UserControl which does not destroy the instance, and allows you to re-use it, via the ''Show method.

My guess is you are describing a scenario where you do want to use ''Hide rather than ''Close: i.e., you do not wish to re-create the pop-up instance (via ''new, or Activator.CreateInstance) every time you need it.


这篇关于调用封闭表格的快捷键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆