[CLOSED] ProcessCmdKey and IMessageFilter.PreFilterMessage



I have an app that (currently) depends on the ProcessCmdKey and IMessageFilter.PreFilterMessage methods to catch mouse clicks and key-presses under various non-traditional circumstances.  For example, I use them to catch the Esc key anywhere in the app, and to catch and ignore clicks on a particular panel if it has another panel on top of it displaying a message, basically to make the lower panel modal without making the entire app modal.

Wisej doesn’t appear to support the IMessageFilter interface or the ProcessCmdKey method.  Are there plans to support these methods in the future?


David Muse


  • You must to post comments

Hi David,

ProcessCmdKey is already supported in Wisej. However, there is a subset of events that Wisej doesn’t wire back to the server unless there is a handler attach and the keyboard events are all part of that list, otherwise the client would have to always generate a server event when pressing anything on the keyboard.

We call them “lazy events”: https://docs.wisej.com/docs/controls/general/lazy-events

So, to be able to override ProcessCmdKey all you need to do it to attach to any keyboard event: this.KeyDown += this.OnKeyDown;

There is a limit to what you can do when pre-processing a keyboard or mouse event. Consider that the event has already occurred and has been fully processed in the browser. All wisej event are asynchronous – as they should be since synchronous ajax has been deprecated long ago and it’s a bad idea in a web app.

Wisej also follows the full bubbling of the native browser events, so you can process keyboard and mouse events at the parent level.

We are unable to add IMessageFilter since it takes a Message argument and we’d have to convert events to windows sdk message codes, etc.

If you send a small app showing the key features you need we can better asses what to add and what’s already supported.



  • You must to post comments

Thanks for the info Luca.  I still can’t seem to get it to work though.

this.KeyDown += this.OnKeyDown

doesn’t compile because OnKeyDown doesn’t have the correct signature to be an event handler.

This does compile:

this.KeyDown += MyClass_KeyDown;

private void MyClass_KeyDown(object sender, KeyEventArgs e)

Is that what you mean?

If I put debug in MyClass_KeyDown though, it is never executed.  Also, if I put debug in my ProcessCmdKey method, it is never executed.

This is how I declared ProcessCmdKey:

protected override bool ProcessCmdKey(Keys keyData)

Is that correct?  I.e. without the ref Message argument that the winforms method has?

Also, I was reading about lazy events, and it says that they “are not fired back to the server unless the application has specifically attached to the handler.”  Does that mean that if “KeyDown += something” then the key-down event will be passed back to the server, but otherwise KeyDown events will not be passed back to the server?



  • You must to post comments


both enhancements are included in the latest build (1.3.14).

Best regards

  • You must to post comments

I have logged two enhancements:

  • WJ-7822: Add support for the ContainerControl.KeyPreview property.
  • WJ-7821: Add support for the PreviewKeyDown event.
  • You must to post comments
Showing 4 results