コード例 #1
0
 protected virtual IntPtr OwnerWndProc(IntPtr hWnd, int msg, IntPtr wparam, IntPtr lparam)
 {
     if (msg == helpMsg)
     {
         try {
             OnHelpRequest(EventArgs.Empty);
         }
         catch (Exception e) {
             Application.OnThreadException(e);
         }
         return(IntPtr.Zero);
     }
     return(UnsafeNativeMethods.CallWindowProc(defOwnerWndProc, hWnd, msg, wparam, lparam));
 }
コード例 #2
0
        /// <summary>
        ///  Invokes the default window procedure associated with this Window. It is
        ///  an error to call this method when the Handle property is zero.
        /// </summary>
        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 = UnsafeNativeMethods.DefWindowProc(m.HWnd, m.Msg, m.WParam, m.LParam);
                    return;
                }
                m.Result = UnsafeNativeMethods.CallWindowProc(_priorWindowProcHandle, m.HWnd, m.Msg, m.WParam, m.LParam);
            }
            else
            {
                m.Result = PreviousWindow.Callback(m.HWnd, (User32.WindowMessage)m.Msg, m.WParam, m.LParam);
            }
        }