Connecting Tech Pros Worldwide Help | Site Map

MenuItem occuring multiple times ....

Newbie
 
Join Date: Mar 2008
Posts: 2
#1: Oct 20 '08
I am adding a menu item by Shell extension in windows mobile.
The extension is for Menu in Context Card summary.

I add two menu items. One MenuItem is seperator and another is with a Command ID.
The seperator menu item just keeps adding every time the menu is rendered.

Any idea why is it happening ?

Code :

STDMETHODCALLTYPE MenuExtension::QueryContextMenu(
__in HMENU menuHandle,
__in UINT indexMenu,
__in UINT commandIdFirst,
__in UINT commandIdLast,
__in UINT flags
){
..
..
result = InsertMenuItem(menuHandle,
indexMenu,
commandIdFirst,
L"Extension");

result = ::InsertMenu(menuHandle, 0 ,
MF_GRAYED | MF_BYPOSITION,
commandIdFirst, L"Extension");

}
markmcgookin's Avatar
Moderator
 
Join Date: Dec 2006
Location: Northern Ireland / England
Posts: 546
#2: Oct 21 '08

re: MenuItem occuring multiple times ....


Is this sitting in a loop? ... if you run this code more than once, are you clearing your menu items in between running it if you are not disposing of the form in between calls?

If you put a breakpoint on your adding calls, then run the app in debug mode, you sill be able to step through the code and find out what is causing it to be run multiple times.

Is this whole applicaiton written in unsafe code? Can you not find a simpler way to add the menu items than using the shell extension?
Reply