public override bool PreProcessMessage(ref Message message)
 {
     if (this.IsUserMode)
     {
         if (this.GetActiveXHostState(ActiveXHelper.SiteProcessedInputKey))
         {
             return(base.PreProcessMessage(ref message));
         }
         NativeMethods.MSG msg = (NativeMethods.MSG)message;
         this.SetActiveXHostState(ActiveXHelper.SiteProcessedInputKey, false);
         try
         {
             if (this.activeXOleInPlaceObject != null)
             {
                 NativeMethods.HRESULT accelatorTranslated = this.activexOleInPlaceActiveObject.TranslateAccelerator(ref msg);
                 if (accelatorTranslated == NativeMethods.HRESULT.S_OK)
                 {
                     return(true);
                 }
                 message.Msg    = msg.message;
                 message.WParam = msg.wParam;
                 message.LParam = msg.lParam;
                 message.HWnd   = msg.hwnd;
                 if (accelatorTranslated == NativeMethods.HRESULT.S_FALSE)
                 {
                     return(base.PreProcessMessage(ref message));
                 }
                 if (this.GetActiveXHostState(ActiveXHelper.SiteProcessedInputKey))
                 {
                     return(base.PreProcessMessage(ref message));
                 }
                 return(false);
             }
         }
         finally
         {
             this.SetActiveXHostState(ActiveXHelper.SiteProcessedInputKey, false);
         }
     }
     return(false);
 }
 protected override bool ProcessMnemonic(char charCode)
 {
     if (base.CanSelect)
     {
         try
         {
             NativeMethods.tagCONTROLINFO controlInfo = new NativeMethods.tagCONTROLINFO();
             if (NativeMethods.Succeeded(this.activeXOleControl.GetControlInfo(controlInfo)))
             {
                 NativeMethods.MSG msg = new NativeMethods.MSG();
                 msg.hwnd    = IntPtr.Zero;
                 msg.message = 260;
                 msg.wParam  = (IntPtr)char.ToUpper(charCode, CultureInfo.CurrentCulture);
                 msg.lParam  = (IntPtr)0x20180001;
                 msg.time    = SafeNativeMethods.GetTickCount();
                 NativeMethods.POINT cursorPos = new NativeMethods.POINT();
                 UnsafeNativeMethods.GetCursorPos(cursorPos);
                 msg.pt   = new NativeMethods._POINTL();
                 msg.pt.x = cursorPos.x;
                 msg.pt.y = cursorPos.y;
                 if (!SafeNativeMethods.IsAccelerator(new HandleRef(controlInfo, controlInfo.hAccel), controlInfo.cAccel, ref msg, null))
                 {
                     return(false);
                 }
                 this.activeXOleControl.OnMnemonic(ref msg);
                 this.Focus();
                 return(true);
             }
         }
         catch (Exception ex)
         {
             if (Utils.IsCriticalException(ex))
             {
                 throw;
             }
         }
     }
     return(false);
 }
Beispiel #3
0
            /// <summary>
            /// Instructs the container to process a specified keystroke.
            /// </summary>
            /// <param name="pMsg">Pointer to the <see cref="NativeMethods.MSG"/> structure describing the keystroke to be processed.</param>
            /// <param name="grfModifiers">Flags describing the state of the Control, Alt, and Shift keys. The value of the flag can be any valid <see cref="NativeMethods.tagKEYMODIFIERS"/> enumeration values.</param>
            /// <returns>
            ///     <see langword="false"/> if the container processed the message; otherwise <see langword="true"/>.
            /// </returns>
            NativeMethods.HRESULT UnsafeNativeMethods.IOleControlSite.TranslateAccelerator(ref NativeMethods.MSG pMsg, NativeMethods.tagKEYMODIFIERS grfModifiers)
            {
                try
                {
                    this.Host.SetActiveXHostState(ActiveXHelper.SiteProcessedInputKey, true);

                    Message message = (Message)pMsg;

                    return((this.Host.PreProcessControlMessage(ref message) == PreProcessControlState.MessageProcessed) ? NativeMethods.HRESULT.S_OK : NativeMethods.HRESULT.S_FALSE);
                }
                finally
                {
                    this.Host.SetActiveXHostState(ActiveXHelper.SiteProcessedInputKey, false);
                }
            }
 public static extern bool IsAccelerator(HandleRef hAccel, int cAccelEntries, [In] ref NativeMethods.MSG lpMsg, short[] lpwCmd);
 NativeMethods.HRESULT UnsafeNativeMethods.IOleInPlaceFrame.TranslateAccelerator(ref NativeMethods.MSG lpmsg, short wID)
 {
     return(NativeMethods.HRESULT.S_FALSE);
 }