Hi,
i m hooking the messages that come whenever any menu item is clicked. This is done on a global scale i.e. it handles all the msgs generated for any appln.
Now i 've to do this thing for only the "Help" menu item, as this is the most common one. I want to check whether the clicked menu item has the "Help" caption or not. This can't be done with the ID, as diff appln have different CtrlIDs. I think it can be done using the GetMenuItemInfo (). Butsomehow i'm not able to fill up MENUITEMINFO struct. Heres the code snippet i'm using.
if (lMsg->message == WM_MENUSELECT)
{
if ((HIWORD(lMsg->wParam) == 1))
{
TCHAR strText[MAX_S] = {0};
HWND hItem = GetDlgItem ((HWND)lMsg->lParam, LOWORD (lMsg->wParam));
GetWindowText(hItem, strText, MAX_S);
if(_tcscmp(strText, _T("&Help")) == 0)
{
MessageBox (NULL, _T("Press F1"), _T("Help Hooked."), MB_OK);
}
}
}
here i always receive "strText" as blank.
I've also tried using GetMenuItemInfo () like this.
PMSG lMsg = (PMSG) (lParam); // lParam is received in SysMsgProc
HMENU hMenu = (HMENU) lMsg->lParam;
MII.cbSize = sizeof (MENUITEMINFO);
bVal = GetMenuItemInfo (hMenu, LOWORD(lMsg->wParam), FALSE, &MII);
but bVal is always zero.
Folks Plz help me out. I m stuck like anything.