コード例 #1
0
 // Route the message to the control
 //
 public void ToControl(ref Message m)
 {
     //Console.WriteLine ("Control: " + ((Native.Msg)m.Msg).ToString ());
     if (_oldTarget != null)
     {
         _oldTarget.OnMessage(ref m);
     }
 }
コード例 #2
0
ファイル: SafeWindowTarget.cs プロジェクト: dotnet/ef6tools
 /// <devdoc>
 ///     The main wndproc for the control.  Wrapped to display non-critical exceptions to the user.
 /// </devdoc>
 void IWindowTarget.OnMessage(ref Message m)
 {
     try
     {
         inner.OnMessage(ref m);
     }
     catch (Exception ex)
     {
         if (CriticalException.ThrowOrShow(serviceProvider, ex))
         {
             throw;
         }
     }
 }
コード例 #3
0
 public static bool WndOverride(ref Message m)
 {
     lock (WndOverrides)
     {
         if (WndOverrides.Contains(m.Msg))
         {
             // do we need to handle multiple overrides, or overrides
             // that choose not to do anything?
             IWindowTarget iw = (IWindowTarget)WndOverrides[m.Msg];
             iw.OnMessage(ref m);
             return(true);
         }
         else
         {
             return(false);
         }
     }
 }
コード例 #4
0
        /// <summary>
        ///  Called to do control-specific processing for this window.
        /// </summary>
        void IWindowTarget.OnMessage(ref Message m)
        {
            // Get the Designer for the currently selected item on the Designer...
            // SET STATE ..
            ignoreMessages = false;

            // Here lets query for the ISupportInSituService.
            // If we find the service then ask if it has a designer which is interested
            // in getting the keychars by querying the IgnoreMessages.
            if ((m.Msg >= (int)User32.WM.KEYFIRST && m.Msg <= (int)User32.WM.KEYLAST) ||
                (m.Msg >= (int)User32.WM.IME_STARTCOMPOSITION && m.Msg <= (int)User32.WM.IME_COMPOSITION))
            {
                if (InSituSupportService != null)
                {
                    ignoreMessages = InSituSupportService.IgnoreMessages;
                }
            }

            switch (m.Msg)
            {
            case WM_PRIVATE_POSTCHAR:

                if (bufferedChars == null)
                {
                    return;
                }

                // recreate the keystroke to the newly activated window
                IntPtr hWnd;
                if (!ignoreMessages)
                {
                    hWnd = User32.GetFocus();
                }
                else
                {
                    if (InSituSupportService != null)
                    {
                        hWnd = InSituSupportService.GetEditWindow();
                    }
                    else
                    {
                        hWnd = User32.GetFocus();
                    }
                }

                if (hWnd != m.HWnd)
                {
                    foreach (BufferedKey bk in bufferedChars)
                    {
                        if (bk.KeyChar.MsgInternal == User32.WM.CHAR)
                        {
                            if (bk.KeyDown.MsgInternal != 0)
                            {
                                User32.SendMessageW(hWnd, User32.WM.KEYDOWN, bk.KeyDown.WParamInternal, bk.KeyDown.LParamInternal);
                            }

                            User32.SendMessageW(hWnd, User32.WM.CHAR, bk.KeyChar.WParamInternal, bk.KeyChar.LParamInternal);
                            if (bk.KeyUp.MsgInternal != 0)
                            {
                                User32.SendMessageW(hWnd, User32.WM.KEYUP, bk.KeyUp.WParamInternal, bk.KeyUp.LParamInternal);
                            }
                        }
                        else
                        {
                            User32.SendMessageW(hWnd, bk.KeyChar.MsgInternal, bk.KeyChar.WParamInternal, bk.KeyChar.LParamInternal);
                        }
                    }
                }

                bufferedChars.Clear();
                return;

            case (int)User32.WM.KEYDOWN:
                lastKeyDown = m;
                break;

            case (int)User32.WM.IME_ENDCOMPOSITION:
            case (int)User32.WM.KEYUP:
                lastKeyDown.Msg = 0;
                break;

            case (int)User32.WM.CHAR:
            case (int)User32.WM.IME_STARTCOMPOSITION:
            case (int)User32.WM.IME_COMPOSITION:
                if ((Control.ModifierKeys & (Keys.Control | Keys.Alt)) != 0)
                {
                    break;
                }

                if (bufferedChars == null)
                {
                    bufferedChars = new ArrayList();
                }

                bufferedChars.Add(new BufferedKey(lastKeyDown, m, lastKeyDown));

                if (!ignoreMessages && MenuCommandService != null)
                {
                    // throw the properties window command, we will redo the keystroke when we actually
                    // lose focus
                    postCharMessage = true;
                    MenuCommandService.GlobalInvoke(StandardCommands.PropertiesWindow);
                }
                else if (ignoreMessages && m.Msg != (int)User32.WM.IME_COMPOSITION)
                {
                    if (InSituSupportService != null)
                    {
                        postCharMessage = true;
                        InSituSupportService.HandleKeyChar();
                    }
                }

                if (postCharMessage)
                {
                    // If copy of message has been buffered for forwarding, eat the original now
                    return;
                }

                break;

            case (int)User32.WM.KILLFOCUS:
                if (postCharMessage)
                {
                    // see ASURT 45313
                    // now that we've actually lost focus, post this message to the queue.  This allows
                    // any activity that's in the queue to settle down before our characters are posted.
                    // to the queue.
                    //
                    // we post because we need to allow the focus to actually happen before we send
                    // our strokes so we know where to send them
                    //
                    // we can't use the wParam here because it may not be the actual window that needs
                    // to pick up the strokes.
                    //
                    User32.PostMessageW(target.Handle, (User32.WM)WM_PRIVATE_POSTCHAR, IntPtr.Zero, IntPtr.Zero);
                    postCharMessage = false;
                }

                break;
            }

            if (oldTarget != null)
            {
                oldTarget.OnMessage(ref m);
            }
        }
コード例 #5
0
 public void DefWndProc(ref Message m)
 {
     _oldTarget.OnMessage(ref m);
 }