如果我在 C#、最大化、无边框程序运行时按下 .LNK 文件快捷键,该快捷键将不再起作用
对于可能由此问题引起的更一般的行为,另请阅读:
我正在编写一个 C# 程序,使用 .NET 2.0 和 WinForms 以及 Visual C# 2008 Express。我使用的是 Windows 7,但问题也出现在 Windows XP 下。
重要提示:主窗体的 FormBorderStyle 属性设置为 None,并将 WindowState 设置为 Maximized。
我在桌面上为我的程序创建了一个快捷方式文件(.LNK),并在“属性”对话框中定义了一个快捷键(假设是 Ctrl+F11,但问题与我尝试过的任何其他快捷键相同)。当我在 Windows 中按 Ctrl+F11 时,我的程序可以正常启动。
但是,如果我在程序运行时按 Ctrl+F11,则不会发生任何事情(即使我将主窗体的 KeyPreview 属性设置为 true 并分配 KeyDown 事件处理程序,也不会生成任何按键按下事件),但是在我关闭程序中,当我再次尝试按 Ctrl+F11 时,该快捷方式在 Windows 中不再起作用。我必须更改它或等待更长的时间才能再次工作(但是目前还不清楚它如何开始再次工作)。
如果我在程序运行时不按Ctrl+F11,则关闭程序后,下次使用快捷键时,它可以正常工作。
这个问题阻止我使用 .LNK 快捷键功能为我的 C#、WinForms、.NET 2.0 程序定义没有窗体边框且最大化的快捷键。
我可以在我的 C# WinForms 程序中做些什么来解决这个问题吗?
谢谢
For a more general behavior probably caused by this problem please also read:
I'm writing a C# program, using .NET 2.0 and WinForms and Visual C# 2008 Express. I'm using Windows 7 but the problem is also under Windows XP.
Important: the FormBorderStyle property of the main form is set to None, and the WindowState to Maximized.
I created a shortcut file (.LNK) to my program on the Desktop, and I defined a shortcut key in the Properties dialog box (let's say Ctrl+F11, but the problem is the same with any other shortcut keys I tried). When I press Ctrl+F11 in Windows, my program starts fine.
However, if I press Ctrl+F11 while my program is running, nothing happens (and no key down event is generated even if I set the KeyPreview property of the main form to true and assign a KeyDown event handler), but after I close the program, when I try again to press Ctrl+F11, the shortcut no longer works in Windows. I have to change it or wait a longer time until it works again (however it's not very clear how it starts to work again).
If I don't press Ctrl+F11 while my program is running, after I close it, the next time I use the shortcut key, it works fine.
This problem prevents me for using the .LNK shortcut key feature to define a shortcut key for my C#, WinForms, .NET 2.0 program that has no form border and it is maximized.
Is there anything I can do in my C# WinForms program to solve this problem?
Thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论