当前位置: 首页>>代码示例>>C#>>正文


C# UnsafeNativeMethods.QueryRange方法代码示例

本文整理汇总了C#中MS.Win32.UnsafeNativeMethods.QueryRange方法的典型用法代码示例。如果您正苦于以下问题:C# UnsafeNativeMethods.QueryRange方法的具体用法?C# UnsafeNativeMethods.QueryRange怎么用?C# UnsafeNativeMethods.QueryRange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MS.Win32.UnsafeNativeMethods的用法示例。


在下文中一共展示了UnsafeNativeMethods.QueryRange方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetFnReconv

        private bool GetFnReconv(ITextPointer textStart, ITextPointer textEnd, out UnsafeNativeMethods.ITfFnReconversion funcReconv, out UnsafeNativeMethods.ITfRange rangeNew)
        {
            UnsafeNativeMethods.ITfContext context;
            UnsafeNativeMethods.ITfRange range;
            UnsafeNativeMethods.ITfRangeACP rangeACP;
            bool fReconvertable = false;

            funcReconv = null;
            rangeNew = null;

            // Create ITfRangeACP for the current selection.
            //  1. Get the context from the document manager and call GetStart to get the instance of
            //     ITfRange.
            //  2. QI the ITfRange to get ITfRangeACP.
            //  3. Get start and end of the current selection from TextContainer.
            //  4. Set extent of the ITfRangeACP.
            DocumentManager.GetBase(out context);
            context.GetStart(EditCookie, out range);
            rangeACP = range as UnsafeNativeMethods.ITfRangeACP;
            int start = textStart.CharOffset;
            int end = textEnd.CharOffset;
            rangeACP.SetExtent(start, end - start);

            // Readonly fields can not be passed ref to the interface methods.
            // Create pads for them.
            Guid guidSysFunc = UnsafeNativeMethods.GUID_SYSTEM_FUNCTIONPROVIDER;
            Guid guidNull = UnsafeNativeMethods.Guid_Null;
            Guid iidFnReconv = UnsafeNativeMethods.IID_ITfFnReconversion;

            UnsafeNativeMethods.ITfFunctionProvider functionPrv;

            // ThreadMgr Method call will be marshalled to the dispatcher thread since Ciecro is STA.
            _textservicesHost.ThreadManager.GetFunctionProvider(ref guidSysFunc, out functionPrv);

            object obj;

            // ITfFnReconversion is always available in SystemFunctionProvider.
            functionPrv.GetFunction(ref guidNull, ref iidFnReconv, out obj);
            funcReconv = obj as UnsafeNativeMethods.ITfFnReconversion;
            funcReconv.QueryRange(range, out rangeNew, out fReconvertable);


            // release objects.
            Marshal.ReleaseComObject(functionPrv);

            if (!fReconvertable)
            {
                Marshal.ReleaseComObject(funcReconv);
                funcReconv = null;
            }

            Marshal.ReleaseComObject(range);
            Marshal.ReleaseComObject(context);

            return fReconvertable;
        }
开发者ID:mind0n,项目名称:hive,代码行数:56,代码来源:TextStore.cs


注:本文中的MS.Win32.UnsafeNativeMethods.QueryRange方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。