views:

184

answers:

2

I'm using a ContextMenuStrip to show some options to the user when they mouse over cells in a table, by calling its Show(Control, int, int) method from within a the table's MouseMove event, passing the table in as the Control parameter.

If the app isn't active, everything works as intended; but if the app is active, then the MouseMove events stop firing once the ContextMenuStrip is shown.

How do I receive mouse move events while showing a ContextMenuStrip? I don't want to add hooks or an application filter, I just want the inactive-app behaviour even when the app is active.

A: 

that's not possible, when the context menu strip is shown, the menu windows captures the mouse

Benny
so why does it work when the application is inactive?
Simon
what do you mean, "application is inactive" ?
serhio
+1  A: 

It is not just a mouse capture, that would be easy to work around. There's an internal class named "ModalMenuFilter" that is activated when a toolstrip dropdown is displayed that filters various messages. Including WM_MOUSEMOVE. It does this by using SetWindowsHookEx(). It works when your app isn't active because this hook is only installed when your form is active.

None of this is accessible from your code, you'd have to use Reflection. Looks to me that you can use ModalMenuFilter.RemoveActiveToolStrip() to disable the filter. Have a look-see with Reflector. This more than likely causes other problems however.

Hans Passant