So your ToolStrip buttons don't click

If you're using the ToolStrip control to group buttons in your application you might run into an issue where the buttons on the ToolStrip don't fire the click event when pressed. If you give the window focus and then click, the buttons work as expected.

This issue seems to plague only the ToolStrip (and its derived types), and stems from MA_ACTIVATEANDEAT, a return value that comes after the WM_MOUSEACTIVATE message is received.

Most controls will return MA_ACTIVATE after receiving the WM_MOUSEACTIVATE message, meaning that the window will become active with the mouse click and that subsequent messages can proceed as usual on the active window.

I used Winspector to observe the behavior and noticed the activate-and-eat message. One of the first posts you'll find when researching that value comes from Rick Brewster, who outlines a solution that served as the base for my own.

toolstrip with clickthrough

The solution is simple enough: create a new control that uses ToolStrip as a base. Process the window messages as usual. Put in a special case to detect the mouse-activate and activate-and-eat combo. If detected, change the result from activate-and-eat to activate.

Now your ToolStrip will respond to clicks even if the window isn't active, which is the behavior you see in most of your other controls anyway.

Here's the source code.