views:

213

answers:

0

For a more general behavior probably caused by this problem please also read:

http://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