SoFunction
Updated on 2025-04-06

How to block the right mouse button by spreadsheetgear plug-in

Mouse_up, which I just used, can capture events, but does not have the Handled attribute of the KeyPress event.

Discover a relatively simple method.

1. Let the form class inherit the IMessageFilter interface first
2. Add:(this);
3. Add to the code:

Copy the codeThe code is as follows:

public bool PreFilterMessage(ref MyMessage)
{
//Not respond to the right-click message
    if(>=516 && <=517)
    {
        return true;
    }
    return false;
}

4. You can put() anywhere you want to work, and you can (this)

Follow the steps to successfully block it.

There is another problem after blocking, that is, after double-clicking, the right-click in the content area that comes with the system is also blocked.