예제 #1
0
        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);
            }
        }
예제 #2
0
        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);
            }
        }
예제 #3
0
파일: NiShell.cs 프로젝트: netide/netide
        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);
            }
        }
예제 #4
0
파일: PageHost.cs 프로젝트: netide/netide
            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);
                }
            }
예제 #5
0
        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);
        }
예제 #6
0
파일: NiPackage.cs 프로젝트: netide/netide
        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);
            }
        }