如果我在 C#、最大化、无边框程序运行时按下 .LNK 文件快捷键,该快捷键将不再起作用

发布于 2024-08-16 22:34:08 字数 986 浏览 10 评论 0原文

对于可能由此问题引起的更一般的行为,另请阅读:

https://stackoverflow.com/questions/2042925/shortcut-keys-define-in-lnk-files-do-not-work-if-im-running-ac- winforms-prog

我正在编写一个 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:

https://stackoverflow.com/questions/2042925/shortcut-keys-defined-in-lnk-files-do-not-work-if-im-running-a-c-winforms-prog

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文