views:

221

answers:

3

i want to know which menuitem is clicked using WH_GETMESSAGE hook.can somebody help me please...from one week i stuck with this problem? plz provide a way how can we achive this..using win32 dll. i am working on vc++6.0.

Thanks in advance....

A: 

With WH_GETMESSAGE you can monitor any message.

When you catch WM_MENUSELECT you can examine the wParam to get the id/index.

Nick D
A: 

Hi Nick, thanks for your reply..from past one week i stuck with this problem. previously i tried with WH_CALLWNDPROC hook and i am able get WM_MENUSELECT msg and i recored menu information(which menu item user visited).but i want to know which menu item is clicked(when i clicked menu item it is generating WM_COMMAND msg..i used spy++)

by using this code i am able to know identifier of the menu item in getmessage hook

WORD identifier=LOWORD(pMsg->wParam); it is giving interger value..( is it possible to know identifier as IDM_XXX ?). but i am not able to get menu information as it is possible with callwndproc hook.

please help me..i not found answer anywhere...

pasham
A: 

from MSDN..

WM_MENUSELECT

wParam

The low-order word specifies the menu item or submenu index. If the selected item is a command item, this parameter contains the identifier of the menu item.

If the selected item opens a drop-down menu or submenu, this parameter contains the index of the drop-down menu or submenu in the main menu, and the lParam parameter contains the handle to the main (clicked) menu; use the GetSubMenu function to get the menu handle to the drop-down menu or submenu.

once you had the menu handle, you can always do GetMenuItemInfo / GetMenuItemID / GetMenuInfo etc...

YeenFei