Tuesday, November 27, 2007

Processing Windows Message C#

Processing Windows Message C#

In System.Windows.Forms.Form we can override WinProc  

    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        public enum WindowsMessages : int
        {
            WM_CLOSE = 0x0010,
            WM_QUIT = 0x0012
        }
        protected override void WndProc(ref Message m)
        {
            switch (m.Msg)
            {
                case (int)WindowsMessages.WM_CLOSE:
                    MessageBox.Show("Close");

                    break;
            }
            base.WndProc(ref m);
        }
    }

 

 

No comments: