I created hotkeys in my application using RegisterHotkey function, like this
[DllImport("user32.dll")]
public static extern bool RegisterHotKey(IntPtr hWnd, int id, int fsModifiers, int vlc);
...
RegisterHotKey(FormHandle, HOTSAVE, MOD_CONTROL, (int)'S');
Here FormHandle is the handle of the main form of the app, HOTSAVE – is a constant – an identifier for a hotkey.
The problem is, my application receives hotkey messages even when it is not in focus, thus preventing other applications from handling their hotkeys (e.g. Ctrl+S in Notepad won’t work).
Could anyone please point out where the problem is? Thanks.
You are confusing hotkeys with keyboard accelerators.
Hotkeys are always global, that’s why you have to register them.
Keyboard accelerators however are process/window/dialog specific and usually stored in the application resources.
More about keyboard accelerators here