Re: trapping F1 in a class derived from CFileDialogImpl [modified]
-
Hello, I'm using Visual Studio 2008 and I'm trying to trap the 'F1' key in a class derived from CFileDialogImpl (found in Windows Template Library 8.0). I've tried a number of things including adding the function:
LRESULT _OnHelp(int /*idCtrl*/, LPNMHDR pnmh, BOOL& /*bHandled*/)
I've also tried adding the handlers WM_HELP and WM_KEYDOWN, but this doesn't work. Lastly, I've done a number of searches on Google to try to find the answer, but I still haven't figured it out. How do I trap the 'F1' key? Any help or suggestions are appreciated.
Regards, Mike
modified on Tuesday, June 15, 2010 8:37 AM
-
Hello, I'm using Visual Studio 2008 and I'm trying to trap the 'F1' key in a class derived from CFileDialogImpl (found in Windows Template Library 8.0). I've tried a number of things including adding the function:
LRESULT _OnHelp(int /*idCtrl*/, LPNMHDR pnmh, BOOL& /*bHandled*/)
I've also tried adding the handlers WM_HELP and WM_KEYDOWN, but this doesn't work. Lastly, I've done a number of searches on Google to try to find the answer, but I still haven't figured it out. How do I trap the 'F1' key? Any help or suggestions are appreciated.
Regards, Mike
modified on Tuesday, June 15, 2010 8:37 AM
-
I know of no way to use PreTranslateMessage for the CFileDialogImpl class. If I'm wrong, please let me know. Regards, Mike
-
Ah sorry, got a bit MFC blind there. Have you tried replacing the windows procedure with your own, sort of like a proxy to the original? I owe you one...
-
No problem and I appreciate your effort. I'm not exactly sure what you mean by replacing the windows procedure. Could you elaborate on that a bit? Which windows procedure?
Regards, Mike
The idea is that if you can find the HWND for the file dialog, you could replace its WinProc[^]. All messages are routed through this method. So basically, remove the old WinProc, add your own (all using SetWindowLongPtr[^]), and in your own just redirect all messages to the original, intercepting the F1 keystroke. This will get you something like the MFC PreTranslateMessage ability.