Click here to Skip to main content
15,896,557 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I registered the hot key "Ctrl + s" for my application to show and hide a panel
VB
using[DllImport("user32", SetLastError = true)] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool RegisterHotKey(IntPtr hwnd, int id, uint fsModifiers, uint vk);

method, it's working fine on my application.


But my problem is when i opened my application and opened a notepad typed something and tried to save the notepad, it is not saving and in the back side of the notepad my application's, the panel is showing and hiding.

Thanks and Regards
Dhilip.R
Posted
Updated 7-Dec-11 1:23am
v2
Comments
DaveAuld 7-Dec-11 7:46am    
What did you expect to happen? You have registered a global hot key, and you have assigned an already used application key sequence, so your app is capturing that sequence.

With RegisterHotKey you define a system-wide hotkey. Windows does not warn about hotkey collisions and can result in unexpected behavior. In your case, your gobal hotkey gets priority over application hotkeys of other applications.

http://msdn.microsoft.com/en-us/library/windows/desktop/ms646309%28v=vs.85%29.aspx[^]

Check this link for some examples on how to implement a hotkey (example 3 and 4 are most interesting for you)
http://windowscoding.com/blogs/blake/archive/2009/05/19/how-to-register-a-keyboard-shortcut-hot-key-in-a-net-windows-forms-application.aspx[^]

Good luck!
 
Share this answer
 
v2
Have a look through this oage;
http://windowscoding.com/blogs/blake/archive/2009/05/19/how-to-register-a-keyboard-shortcut-hot-key-in-a-net-windows-forms-application.aspx[^]

There are several different ways, and you are maybe just looking for Method #3
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900