create MessageFilter - System.Windows.Forms

Is there a possiblity to create a Messagefilter for use in a loop?
Based on the Acad 'System.Windows.Forms.Application.AddMessageFilter(filter)'
Therefore you need to using System.Windows.Forms which seems not to be available in my C# environment?

Comments

  • I use something like this for my .NET project

    using WinForms = System.Windows.Forms;
    using Keys = System.Windows.Forms.Keys;
    
    public class SpaceRightClickFilter : WinForms.IMessageFilter
    {
        public bool canceled = false;
        public bool PreFilterMessage(ref WinForms.Message m)
        {
            int WM_RIGHTCLICK = 0x0205; 
            int WM_KEYDOWN = 0x0100;
            Keys kc = (Keys) (int) m.WParam & Keys.KeyCode;
            // check for space press or right click
            if ((m.Msg == WM_KEYDOWN && (kc==Keys.Space)) || m.Msg==WM_RIGHTCLICK)
            {
                canceled = true;
            }
            // never falter
            return false;
        }
    }
    

    Hope that helps

This discussion has been closed.