I am using TrackPopupMenu (taken from user32.dll) to open a context
menu within an editor. About 1/2 of the time, the menu works as
expected--opens on right click, and you can move away and it
disappears, or choose one of the menu items and the command fires.
However, sometimes instead, the context menu opens and then instantly
the options disappear and just a tiny box is left instead of the menu
with items.
I have tried other fixes I found for TrackPopupMenu (using
SetForeground and PostMessage) and setting different flags. None of
these seem to matter. My menu items are not getting disposed (according
to breakpoint set in debugger) and I can't find any other events that
would be interefering.
Any ideas? As an additional weird fact, there are three different
context menus--one when the mouse is over a link, one for images, and
one for plain text. The problem happens 95% of the time you right click
on a link, about 15% for images, and maybe 5% for plain text.
The call is very simple:
int menuID = User32.TrackPopupMenu(Handle,
TPM.NONOTIFY | TPM.RETURNCMD,
position.X,
position.Y,
0,
parentWindow.Handle,
IntPtr.Zero);
Thanks!
BEP