Reputation: 11
I'm working on an App and it has SubMenu/One more child SubMenu like Edit --> Insert --> Date and few other option. I want to click(sendmessage) to Date menuitem. is there any PinvokeMethod to get handle for multilevel menu Items?
Upvotes: 1
Views: 672
Reputation: 98526
To simulate the click of a menu you do not send any message to the menu itself, you just send the same message that the menu does when clicked. That is, send WM_COMMAND
to the owner window of the menu, with old good SendMessage
.
When choosing an option from a menu, the parameters are:
wParam
: the identifier (16 lower bits) of the command to be sent.lParam
: 0
.If you don't know the value of the identifier, you can use a monitor program such as Spy++
(included with most VS versions) to list the messages sent/received by your program.
Upvotes: 3