kevp
kevp

Reputation: 377

IMessageFilter does not allow me to input into textbox

My windows form application has IMessageFilter functionality. It seems to work except for that it captures key events that are meant to be for input into a textbox.

Is there any way to get around this?

Upvotes: 0

Views: 780

Answers (1)

Hans Passant
Hans Passant

Reputation: 941705

When you implement IMessageFilter, and call Application.AddMessageFilter(), then you see all of the queued input messages for every control on every form that you created. That's entirely the point of using the interface. You could filter, as suggested by the method name, the PreFilterMessage() method supplies the control's window handle in the Message.HWnd argument. Which you can compare to a specific control's Handle property. Or you can use Control.FromHandle() to get a reference to the control that's going to get the message. Return false from the method to prevent the message from getting further processed.

Upvotes: 3

Related Questions