Re: Hot key detecting
On Mar 21, 9:53 am, "Tom Serface" <tom.nos...@camaswood.com> wrote:
You can use GetKeyState() to detect if the Ctrl, Shift, or Alt keys are down
or any combination of them, but a better way to do it would be to use the
Accelerator table for keys unless you're in a dialog. You can assign them
to an ID just like a menu item. You can also do Shift, Ctrl, and Alt
combinations with the keys.
if (pMsg->message == WM_KEYDOWN) {
if((pMsg->wParam == VK_INSERT) && (GetKeyState(VK_SHIFT) & ~1) != 0) {
OnInsertFolder();
return true;
}
else if(pMsg->wParam == VK_INSERT) {
OnInsert();
return true;
}
else if(pMsg->wParam == VK_DELETE) {
OnDelete();
return true;
}
}
GetKeyState() info:http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winu...
Accelerator Table tutorial:http://www.devarticles.com/c/a/Cplusplus/Using-MFC-in-Cplus-Part-2-Me...
How to use accelerator table in a dialog:http://support.microsoft.com/kb/100770
Tom
"Alex" <alsim...@hotmail.com> wrote in message
news:1174484185.614572.223830@n76g2000hsh.googlegroups.com...
Hello, people
How can I catch in my MDI Visual C++/MFC application Hot Key
shortcuts, for example
<Ctrl> + <F4>?
To detect let's say just <F4> in my
CMainFrame::PreTranslateMessage(MSG* pMsg)
I have lines:
if( ( pMsg->message == WM_KEYDOWN ) && ( pMsg->wParam == VK_F4 ) )
{
...// do something
}
But what about <Ctrl> + <F4>?
Thanks in advance
A.- Hide quoted text -
- Show quoted text -
Thanks, Ajay and Tom, indeed, from your responses and some other
articles it appears, that accelerators - it's the base way, so just to
confirm - the way to do it
1.Load accelerator table in InitInstance of my MDI application
2.Override ProcessMessageFilter(... ) function in my application class
And from now on in any of my application window in
::PreTranslateMessage(... pMsg )
I can check if pMsg->wParam is equal to corresponding ID from
accelerator table?
Thanks,
A