/// <summary>
 ///   Processes Windows messages for the subclassed window.
 /// </summary>
 /// <param name="m">The message to process.</param>
 protected virtual void WndProc(ref Message m)
 {
     // Call the original window procedure to process the message.
     if (_originalWindowProc != IntPtr.Zero)
     {
         m.Result = User32.CallWindowProcW(
             _originalWindowProc,
             m.HWnd,
             (User32.WM)m.Msg,
             m.WParam,
             m.LParam);
     }
 }
Example #2
0
        public void DefWndProc(ref Message m)
        {
            if (PreviousWindow == null)
            {
                if (_priorWindowProcHandle == IntPtr.Zero)
                {
                    Debug.Fail($"Can't find a default window procedure for message {m} on class {GetType().Name}");

                    // At this point, there isn't much we can do.  There's a small chance the following
                    // line will allow the rest of the program to run, but don't get your hopes up.
                    m.Result = User32.DefWindowProcW(m.HWnd, (User32.WM)m.Msg, m.WParam, m.LParam);
                    return;
                }
                m.Result = User32.CallWindowProcW(_priorWindowProcHandle, m.HWnd, (User32.WM)m.Msg, m.WParam, m.LParam);
            }
            else
            {
                m.Result = PreviousWindow.Callback(m.HWnd, (User32.WM)m.Msg, m.WParam, m.LParam);
            }
        }