Reputation: 9841
We have MFC application which has around 10 image buttons to which we want to provide shortcut keys. Shortcuts will be customizable. I have implemented shortcuts (with no customization right now) with hotkeys using ON_WM_HOTKEY()
message.
After searching through Goolge I am little confuse. For example, this question is suggesting hotkey is global for OS, and Accelerator is global for application.
Which one I should use with my application. My shortcut keys will be like Ctrl + Shift + A, and will be customizable.
Secondly, where to keep them. Is it usual to store shortcuts in Windows Registry?
Upvotes: 0
Views: 1829
Reputation: 2878
The difference between an accelerator key and a hotkey is as the provided link states; an accelerator key press is registered whenever the registered key combination is pressed while the application has focus (normal behaviour). However if you want to register a key combination that works even if the user is using another application while your application is in the background; go for hotkey. Applications that commonly uses this are clipboard managers, screen grabbers and launchers.
Storing configuration in the registry is what I would recommend, however you could also use configuration files stored in the users profile directory.
Upvotes: 1
Reputation: 37122
Hotkeys added via RegisterHotKey
(or its equivalent in MFC) are definitely system global and you should not use them to trigger functions in your program unless you specifically want the user to be able to trigger them from anywhere.
(e.g. your application might be a screenshot app, and so triggering a function from outside it would make sense)
Normally though you should use accelerators to add keyboard bindings for toolbar buttons etc.
Where you store them is up to you - I would say you should store them wherever you store the rest of your application's configuration data.
Upvotes: 1