How to capture keyboard events ?
-
I m trying to capture particular key combination (For e.g ctrl + s to Save) and then i want to execute my piece of code before call goes to actual " Save " routine ? Can any1 help me ...?
vaibhav
You need to install a KeyBoardHook to achieve this.
Nobody can give you wiser advice than yourself. - Cicero
-
I m trying to capture particular key combination (For e.g ctrl + s to Save) and then i want to execute my piece of code before call goes to actual " Save " routine ? Can any1 help me ...?
vaibhav
You have to filter very "WM_KEYDOWN" message and check whether "CTRL + S" is happend. For that you can override "PreTranslateMessage(pMsg)" . Plz see the code snippet you have to add in "PreTranslateMessage(pMsg)". if ( WM_KEYDOWN == pMsg->message && pMsg->wParam == 0x53 /* 'S' */) { if ( ( ::GetKeyState ( VK_LCONTROL ) & KF_UP ) || ( ::GetKeyState ( VK_RCONTROL ) & KF_UP ) ) { // Ctrl + s pressed. Write ur code here. } } return CDialog::PreTranslateMessage(pMsg);