Capturing keystrokes in menu items (OpenInsight Specific)
At 10 JUL 1998 04:39:40PM Don Bakke wrote:
We are assisting in the conversion of a well used AREV app into OpenInsight. The owner wishes to maintain as much similarity as possible to ease the learning curve for those who upgrade.
One of the features requested is to have the ability for the end user to press F1 for help anywhere in the window (which is no problem) and even when the focus is on a menu item (which is a problem). Is this a possibility at all? I've tried qualifying WM_CHAR and WM_KEYDOWN on the menu items themselves and then redirect their WINMSG event elsewhere to process everything…but nothing seems to get captured.
Any help to get this to work, or at least to tell me it's impossible, would be greatly appreciated.
dbakke@srpcs.com
At 11 JUL 1998 12:06AM deb wrote:
We set up menu items with accelerator keys and then hid the menu items. Got rid of all the menus on the child windows so they use the
mdi window. This is working for us.
At 11 JUL 1998 11:01AM Don Bakke wrote:
Deb,
Thanks, but that's not what I was looking for. We want the user to be able to get help for the menu items themselves. In AREV you could assign help to menu items, in Windows it appears that this is not possible but I wanted a definitive answer. The "closest" thing to it would be to set up a context help button and develop an intercept routine that checks to see if this has been set and then go call the help routine rather than the default function. But since our goal is to duplicate AREV's abilities, we want to exhaust this option first.
dbakke@srpcs.com
At 13 JUL 1998 09:59AM Gene Gleyzer Revelation wrote:
Don,
Unfortunately there is no easy way to do what you want. Menu's painting and processing is done completely internally by Windows, so in order to intercept any events while the menu is "active" you have to install Windows hook using SetWindowsHookEx() function and providing a filter callback that would monitor all the messages and pick the ones you are interested in. This is quite easy when you know exactly what you are looking for. For example, that is how the filter could look like (in C/C++ written application) to intercept F1 for menu items:
…
#define WM_F1DOWN (WM_USER + 100) unique dedicated message … extern HWND hwndMain; application's main window
…
LRESULT FAR PASCAL FilterFunc(int nCode, WPARAM wParam, LPARAM lParam)
{LPMSG lpmsg=(LPMSG) lParam;if (nCode == MSGF_MENU &&lpmsg-]message == WM_KEYDOWN && lpmsg-]wParam == VK_F1){return PostMessage(hwndMain, WM_F1DOWN, nCode, 0L);}return CallNextHookEx(hMsgHook, nCode, wParam, lParam);}
However, in a generic case of Presentation Server it becomes quite an ambiguios (though not impossible) task. I'll put your request for enhancement into our SPR system, but meanwhile you can consider writing a tiny DLL that would do just that. (BTW, you may have noticed that new Microsoft apps do not have this functionality anymore…)
Gene