How can I assign a Fn-Key, for example F5 on the keyboard, to a button in a dialog box? I want that the user can either press the button with the mouse or the corresponding Fn-Key.
I can assign accelerators with '&' in the label text, but I want to use Fn-Keys. I looked in the documentation, but couldn't find the right thing.
mrjt Messages: 705 Registered: March 2007 Location: London
Contributor
I don't think there is a direct way of doing this. What you do is overload the parent window's Key handler:
bool Key(dword key, int count) {
if (key == K_F5) {
button.PseudoPush();
return true;
}
return TopWindow::Key(key, count);
}
Doing it this way also permits user-defined keys. I suggest you look at the reference/AK package or how to do this with very little effort. You basically just have to defined the keys then replace F5 with AK_whatever.
Thanks a lot. I was looking in references and examples, but I think due to staring to much at the screen did not see the AK reference.
So far I don't need to have it user-defined as I'm the only user. Just a small tool for my own use. But might be a good feature for some bigger applications.