case WM_COMMAND :
{ WORD w1 = LOWORD ( wParam );
if ( w1 >= MessageBase &&
w1 < ( MessageBase + NumberOfAccelerators ))
{ // f1 .. f12 pressed
Your code for the function keys here
} else
{ // rest of WM_COMMAND
}
}
break;
I understand you use AppWizard or something like that to make an MFC application. (I don't so I do not know anything of ONPRETRANSLATEMESSAGE, which is MFC I suppose). But if you use AppWizard, you can do this using resources. Insert a new resource, type Accelerator. Choose an unique ID, at the Key field, fill in VK_F1 .. VK_F12, uncheck Ctrl, Alt and Shift and choose Type VirtKey. Do this 12 times, one for each function key.
If you press one of the function keys while the program is running, a WM_COMMAND message is generated, where LOWORD(wParam) == the unique ID-value you have chosen. AT that point you must take the action you have in mind for the function key.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.