I'm working on a program that will add menu items to another program when loaded, and later remove the menu items when unloaded. My problem is removing my separators during unload. Additional menu items may be inserted before, after, or even within the ones I put in, so I can't rely on finding them by position. I can apply an ID to the normal menu items, but according to the documentation, not for separators. In the documentation for the various api calls that add a separator to a menu (AppendMenu, InsertMenu) it states:
MF_SEPARATOR Draws a horizontal dividing line. This flag is used only in a drop-down menu, submenu, or shortcut menu. The line cannot be grayed, disabled, or highlighted. The lpNewItem and uIDNewItem parameters are ignored.

Since the uIDNewItem parameter is ignored, I can't put an ID on it so I can't easily delete it later.

I have tried putting an ID in the normal position and later deleting by that ID, and it seems to work, but I hate to do something specifically disallowed in the documentation.

So, how do I legally tag these separators so I can find them later for deletion?
Posted on 2004-09-23 09:28:49 by JimG
I think you can still put an ID on it and retrieve it. It's just Windows who ignores that parameter, after all you have to submit an ID while creating it.

I wouldn't worry about that :)
Posted on 2004-09-23 12:33:23 by JimmyClif
What I'm worried about is that the description of the function specifically states that it ignores whatever in in the ID when adding the separator. That means the separator should NOT have an ID. It seems to now, but the next version of Windows might not and since they said all along not to use it, I couldn't really complain.
Posted on 2004-09-23 20:03:46 by JimG
I bet lots of code would be broken if they did that, so I wouldn't expect it to happen any time soon... ;)

BTW, any menu item can have an ID, even popup items. Both the APIs and MENUEX resources let you do it. :)
Posted on 2004-09-25 10:53:50 by QvasiModo
Thanks Q-

BTW, any menu item can have an ID, even popup items. Both the APIs and MENUEX resources let you do it.

That's what was bothering me, the API specifically says that it is ignored, wether or not it actually does so. It would have been nice if MS wasn't quite so clear on this.

-Jim
Posted on 2004-09-25 11:33:12 by JimG