HResult INiIsolationClient.PreProcessMessage(ref NiMessage message, out PreProcessMessageResult preProcessMessageResult) { preProcessMessageResult = 0; try { var result = HResult.False; var target = FindTarget(message.HWnd); if (target != null) { Message msg = message; result = target.PreProcessMessage(ref msg) ? HResult.OK : HResult.False; message = msg; if (ControlStubs.ControlGetState2(target, ControlStubs.STATE2_INPUTKEY)) preProcessMessageResult |= PreProcessMessageResult.IsInputKey; if (ControlStubs.ControlGetState2(target, ControlStubs.STATE2_INPUTCHAR)) preProcessMessageResult |= PreProcessMessageResult.IsInputChar; } return result; } catch (Exception ex) { return ErrorUtil.GetHResult(ex); } }
HResult INiIsolationHost.ProcessCmdKey(ref NiMessage message, Keys keyData) { try { Message msg = message; bool result = ProcessCmdKey(ref msg, keyData); message = msg; return result ? HResult.OK : HResult.False; } catch (Exception ex) { return ErrorUtil.GetHResult(ex); } }
public HResult BroadcastPreMessageFilter(ref NiMessage message) { try { if (_preMessageFilterRecursion > 0) return HResult.False; _preMessageFilterRecursion++; try { // We delay resolve the package manager because it is created // after NiShell is. if (_packageManager == null) _packageManager = (NiPackageManager)GetService(typeof(INiPackageManager)); if (MessageFilterUtil.InvokeMessageFilter(ref message)) return HResult.OK; foreach (var package in _packageManager.Packages) { var preMessageFilter = package.Package as INiPreMessageFilter; if ( preMessageFilter != null && ErrorUtil.ThrowOnFailure(preMessageFilter.PreFilterMessage(ref message)) ) return HResult.OK; } return HResult.False; } finally { _preMessageFilterRecursion--; } } catch (Exception ex) { return ErrorUtil.GetHResult(ex); } }
public HResult PreProcessMessage(ref NiMessage message, out PreProcessMessageResult preProcessMessageResult) { preProcessMessageResult = 0; try { if (_page != null) return _page.PreProcessMessage(ref message, out preProcessMessageResult); return HResult.False; } catch (Exception ex) { return ErrorUtil.GetHResult(ex); } }
public static bool InvokeMessageFilter(ref NiMessage message) { // This methods invokes System.Windows.Forms.Application+ThreadContext.ProcessFilters. // The purpose of this is to broadcast pre-filter messages over // AppDomains. The idea is that every AppDomain has a mesage filter. // When this message filter receives a message, it is passed // to INiShell.BroadcastPreFilterMessage. That method invokes // this method on AppDomain 1 and passes it on to all INiPackages // that implement INiPreMessageFilter. That implementation in turn // also invokes this method so that the message is broadcasted to // the rest of the AppDomains. Care must be taken to make sure that // this does not recurse, so all calls to INiShell.BroadcastPreMessageFilter // and MessageFilterUtil.InvokeMessageFilter must be protected with // recursion prevention. return _invokeMessageFilterDelegate(ref message); }
public HResult PreFilterMessage(ref NiMessage message) { try { if (_preMessageFilterRecursion > 0) return HResult.False; _preMessageFilterRecursion++; try { return MessageFilterUtil.InvokeMessageFilter(ref message) ? HResult.OK : HResult.False; } finally { _preMessageFilterRecursion--; } } catch (Exception ex) { return ErrorUtil.GetHResult(ex); } }