wirol

Hi all,

I have one form and multiple controls in it. I want to disable mouse event for all controls by using WndProc. I can receive Mouse messages like WM_MOUSEACTIVATE in my form. But I can't consume it. I mean I don't want to release that messages. For keyboard messages with PreProcessMessage, I can simply return true if I want to handle.

Thanks

WIROL



Re: Windows Forms General HOW TO: Consume mouse message

nobugz

You could have your form implement the IMessageFilter interface. For example:

public partial class Form1 : Form, IMessageFilter {
public Form1() {
InitializeComponent();
Application.AddMessageFilter(this);
}
public bool PreFilterMessage(ref Message m) {
return (m.Msg >= 0x200 && m.Msg <= 0x20E) || (m.Msg >= 0x0A1 && m.Msg <= 0x0AD);
}
}

Remove the test for 0x0A1..0x0AD if you still want to let the user use the mouse to size, move and close the form.





Re: Windows Forms General HOW TO: Consume mouse message

wirol

Thank you very much.

I got it

WIROL