How to use this WndProc in Windows Forms application?

后端 未结 2 1644
慢半拍i
慢半拍i 2021-01-06 23:36

Please guide me how to use this WndProc in Windows Forms application:

private IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam,         


        
2条回答
  •  Happy的楠姐
    2021-01-07 00:35

    You can use Application.AddMessageFilter Method.

    [SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.UnmanagedCode)]
    public class TestMessageFilter : IMessageFilter
    {
        public bool PreFilterMessage(ref Message m)
        {
            // Blocks all the messages relating to the left mouse button. 
            if (m.Msg >= 513 && m.Msg <= 515)
            {
                Console.WriteLine("Processing the messages : " + m.Msg);
                return true;
            }
            return false;
        }
    }
    

提交回复
热议问题