• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Win32.UnsafeNativeMethods类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



UnsafeNativeMethods类属于MS.Win32命名空间,在下文中一共展示了UnsafeNativeMethods类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: OnEndEdit

        internal void OnEndEdit(
            UnsafeNativeMethods.ITfContext context, 
            int ecReadOnly,
            UnsafeNativeMethods.ITfEditRecord editRecord)
        {
            if (_propertyRanges == null)
            {
                _propertyRanges = new TextServicesDisplayAttributePropertyRanges(_textstore);
            }

            _propertyRanges.OnEndEdit(context, ecReadOnly, editRecord);
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:12,代码来源:TextServicesProperty.cs


示例2: DynamicScriptObject

        internal DynamicScriptObject(UnsafeNativeMethods.IDispatch scriptObject)
        {
            if (scriptObject == null)
            {
                throw new ArgumentNullException("scriptObject");
            }

            _scriptObject = scriptObject;

            // In the case of IE, we use IDispatchEx for enhanced security (see InvokeOnScriptObject).
            _scriptObjectEx = _scriptObject as UnsafeNativeMethods.IDispatchEx;
        }
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:12,代码来源:DynamicScriptObject.cs


示例3: OnEndEdit

        internal virtual void OnEndEdit(UnsafeNativeMethods.ITfContext context,
                                        int ecReadOnly, 
                                        UnsafeNativeMethods.ITfEditRecord editRecord) 
        {
            int fetched;
            UnsafeNativeMethods.IEnumTfRanges ranges;
            UnsafeNativeMethods.ITfProperty prop = null;

            ranges = GetPropertyUpdate(editRecord);

            UnsafeNativeMethods.ITfRange [] outRanges;
            outRanges = new UnsafeNativeMethods.ITfRange[1];
            while (ranges.Next(1, outRanges, out fetched) == 0)
            {
                //
                // check the element has enabled dynamic property.
                //
                ITextPointer start;
                ITextPointer end;

                ConvertToTextPosition(outRanges[0], out start, out end);

                if (prop == null)
                    context.GetProperty(ref _guid, out prop);

                UnsafeNativeMethods.IEnumTfRanges rangesProp;

                if (prop.EnumRanges(ecReadOnly, out rangesProp, outRanges[0]) == 0)
                {
                    UnsafeNativeMethods.ITfRange [] outRangesProp;
                    outRangesProp = new UnsafeNativeMethods.ITfRange[1];
                    while (rangesProp.Next(1, outRangesProp, out fetched) == 0)
                    {
                        OnRange(prop, ecReadOnly, outRangesProp[0]);
                        Marshal.ReleaseComObject(outRangesProp[0]);
                    }
                    Marshal.ReleaseComObject(rangesProp);
                }

                Marshal.ReleaseComObject(outRanges[0]);

            }
            Marshal.ReleaseComObject(ranges);
            if (prop != null)
                Marshal.ReleaseComObject(prop);
        }
开发者ID:JianwenSun,项目名称:cc,代码行数:46,代码来源:TextServicesPropertyRanges.cs


示例4: OnRange

        internal override void OnRange(
            UnsafeNativeMethods.ITfProperty property,
            int ecReadOnly, 
            UnsafeNativeMethods.ITfRange range)
        {
            Int32 guidatom = GetInt32Value(ecReadOnly, property, range);
            if (guidatom != 0)
            {
                TextServicesDisplayAttribute  attr;
                attr = GetDisplayAttribute(guidatom);
                if (attr != null)
                {
                    ITextPointer start;
                    ITextPointer end;

                    ConvertToTextPosition(range, out start, out end);

                    attr.Apply(start, end);
                }
            }
        }
开发者ID:JianwenSun,项目名称:cc,代码行数:21,代码来源:TextServicesDisplayAttributePropertyRanges.cs


示例5: OpenColorProfile

 internal void OpenColorProfile(ref UnsafeNativeMethods.PROFILE profile)
 {
     // No need to get rid of the old handle as it will get GC'ed
     _profileHandle = UnsafeNativeMethodsMilCoreApi.Mscms.OpenColorProfile(
         ref profile,
         NativeMethods.PROFILE_READ,     // DesiredAccess
         NativeMethods.FILE_SHARE_READ,  // ShareMode
         NativeMethods.OPEN_EXISTING     // CreationMode
         );
 }
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:10,代码来源:ColorContextHelper.cs


示例6: MouseSink

 internal MouseSink(UnsafeNativeMethods.ITfRangeACP range, UnsafeNativeMethods.ITfMouseSink sink, int cookie)
 {
     _range = new SecurityCriticalDataClass<UnsafeNativeMethods.ITfRangeACP>(range);
     _sink = new SecurityCriticalDataClass<UnsafeNativeMethods.ITfMouseSink>(sink);
     _cookie = cookie;
 }
开发者ID:mind0n,项目名称:hive,代码行数:6,代码来源:TextStore.cs


示例7: EnumToolTipWindows

        // ------------------------------------------------------
        //
        // Private Methods
        //
        // ------------------------------------------------------

        #region Private Methods

        private static bool EnumToolTipWindows(IntPtr hwnd, ref UnsafeNativeMethods.ENUMTOOLTIPWINDOWINFO lParam)
        {
            // Use ProxyGetClassName here instead of GetClassName(),
            // since for a [....] tooltip the latter will return
            // "WindowsForms10.tooltips_class32.app.0.b7ab7b".
            // Instead, ProxyGetClassName uses WM_GETOBJECT with
            // OBJID_QUERYCLASSNAMEIDX, which will return the correct answer.
            if (!ProxyGetClassName(hwnd).Equals("tooltips_class32"))
            {
                return true;
            }

            NativeMethods.TOOLINFO tool = new NativeMethods.TOOLINFO();
            tool.Init(Marshal.SizeOf(typeof(NativeMethods.TOOLINFO)));
            // For tooltips with ids of 0, MFC will create the tooltip with the flag of TTF_IDISHWND.
            // TTF_IDISHWND indicates that the uId member is the window handle to the tool.
            if (lParam.id == 0)
            {
                tool.hwnd = Misc.GetParent(lParam.hwnd);
                tool.uId = unchecked((int)lParam.hwnd);
                tool.uFlags = NativeMethods.TTF_IDISHWND;
            }
            else
            {
                tool.hwnd = lParam.hwnd;
                tool.uId = lParam.id;
            }

            string name = XSendMessage.GetItemText(hwnd, tool);

            // Didn't get anything - continue looking...
            if (string.IsNullOrEmpty(name))
            {
                return true;
            }

            lParam.name = name;

            // Got it - can stop iterating now.
            return false;
        }
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:49,代码来源:Misc.cs


示例8: ProxyGetTitleBarInfo

        // wrapper for GetTitleBarInfo
        internal static bool ProxyGetTitleBarInfo(IntPtr hwnd, out UnsafeNativeMethods.TITLEBARINFO ti)
        {
            ti = new UnsafeNativeMethods.TITLEBARINFO();
            ti.cbSize = Marshal.SizeOf(ti.GetType());

            bool result = UnsafeNativeMethods.GetTitleBarInfo(hwnd, ref ti);
            int lastWin32Error = Marshal.GetLastWin32Error();

            if (!result)
            {
                ThrowWin32ExceptionsIfError(lastWin32Error);
                return false;
            }
            return true;
        }
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:16,代码来源:Misc.cs


示例9: GetInt32Value

        private Int32 GetInt32Value(int ecReadOnly, UnsafeNativeMethods.ITfProperty property, UnsafeNativeMethods.ITfRange range)
        {
            Object obj = GetValue(ecReadOnly, property, range);
            if (obj == null)
                return 0;

            return (Int32)obj;
        }
开发者ID:JianwenSun,项目名称:cc,代码行数:8,代码来源:TextServicesDisplayAttributePropertyRanges.cs


示例10: DoDragDrop

 public static extern void DoDragDrop(IComDataObject dataObject, UnsafeNativeMethods.IOleDropSource dropSource, int allowedEffects, int[] finalEffect);
开发者ID:JianwenSun,项目名称:cc,代码行数:1,代码来源:UnsafeNativeMethodsCLR.cs


示例11:

 int UnsafeNativeMethods.IDocHostUIHandler.GetDropTarget(UnsafeNativeMethods.IOleDropTarget pDropTarget, out UnsafeNativeMethods.IOleDropTarget ppDropTarget) 
 {
     //
     // Set to null no matter what we return, to prevent the marshaller
     // from going crazy if the pointer points to random stuff.
     ppDropTarget = null;
     return NativeMethods.E_NOTIMPL;
 }
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:8,代码来源:webbrowsersite.cs


示例12: RequestAttrsTransitioningAtPosition

 // See msdn's ITextStoreACP documentation for a full description.
 public void RequestAttrsTransitioningAtPosition(int position, int count, Guid[] filterAttributes, UnsafeNativeMethods.AttributeFlags flags)
 {
     throw new COMException(SR.Get(SRID.TextStore_E_NOTIMPL), unchecked((int)0x80004001));
 }
开发者ID:mind0n,项目名称:hive,代码行数:5,代码来源:TextStore.cs


示例13: RequestAttrsAtPosition

        // See msdn's ITextStoreACP documentation for a full description.
        public int RequestAttrsAtPosition(int index, int count, Guid[] filterAttributes, UnsafeNativeMethods.AttributeFlags flags)
        {
            ITextPointer position;

            position = CreatePointerAtCharOffset(index, LogicalDirection.Forward);

            PrepareAttributes((InputScope)position.GetValue(InputMethod.InputScopeProperty),
                              (double)position.GetValue(TextElement.FontSizeProperty),
                              (FontFamily)position.GetValue(TextElement.FontFamilyProperty),
                              (XmlLanguage)position.GetValue(FrameworkContentElement.LanguageProperty),
                              null,
                              count, filterAttributes);

            if (_preparedattributes.Count == 0)
                return NativeMethods.S_FALSE;

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


示例14: RequestSupportedAttrs

        // See msdn's ITextStoreACP documentation for a full description.
        public int RequestSupportedAttrs(UnsafeNativeMethods.AttributeFlags flags, int count, Guid[] filterAttributes)
        {

            // return the default app property value, which target is Scope.
            PrepareAttributes((InputScope)UiScope.GetValue(InputMethod.InputScopeProperty),
                              (double)UiScope.GetValue(TextElement.FontSizeProperty),
                              (FontFamily)UiScope.GetValue(TextElement.FontFamilyProperty),
                              (XmlLanguage)UiScope.GetValue(FrameworkContentElement.LanguageProperty),
                              UiScope as Visual,
                              count, filterAttributes);

            if (_preparedattributes.Count == 0)
                return NativeMethods.S_FALSE;

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


示例15: InsertEmbeddedAtSelection

        // See msdn's ITextStoreACP documentation for a full description.
        public void InsertEmbeddedAtSelection(UnsafeNativeMethods.InsertAtSelectionFlags flags, object obj, out int startIndex, out int endIndex, out UnsafeNativeMethods.TS_TEXTCHANGE change)
        {
            startIndex = -1;
            endIndex = -1;

            change.start = 0;
            change.oldEnd = 0;
            change.newEnd = 0;

            if (IsReadOnly)
            {
                throw new COMException(SR.Get(SRID.TextStore_TS_E_READONLY), UnsafeNativeMethods.TS_E_READONLY);
            }

#if ENABLE_INK_EMBEDDING
            IComDataObject data;

            if (IsReadOnly)
            {
                throw new COMException(SR.Get(SRID.TextStore_TS_E_READONLY), UnsafeNativeMethods.TS_E_READONLY);
            }

            if (!TextSelection.HasConcreteTextContainer)
            {
                throw new COMException(SR.Get(SRID.TextStore_TS_E_FORMAT), UnsafeNativeMethods.TS_E_FORMAT);
            }

            // The object must have IOldDataObject internface.
            // The obj param of InsertEmbedded is IDataObject in Win32 definition.
            data = obj as IComDataObject;
            if (data == null)
            {
                throw new COMException(SR.Get(SRID.TextStore_BadObject), NativeMethods.E_INVALIDARG);
            }

            // Do the insert.
            if ((flags & UnsafeNativeMethods.InsertAtSelectionFlags.TS_IAS_QUERYONLY) == 0)
            {
                InsertEmbeddedAtRange((TextPointer)this.TextSelection.Start, (TextPointer)this.TextSelection.End, data, out change);
            }

            if ((flags & UnsafeNativeMethods.InsertAtSelectionFlags.TS_IAS_NOQUERY) == 0)
            {
                startIndex = this.TextSelection.Start.Offset;
                endIndex = this.TextSelection.End.Offset;
            }
#else
            throw new COMException(SR.Get(SRID.TextStore_TS_E_FORMAT), UnsafeNativeMethods.TS_E_FORMAT);
#endif
        }
开发者ID:mind0n,项目名称:hive,代码行数:51,代码来源:TextStore.cs


示例16: InsertTextAtSelection

        // See msdn's ITextStoreACP documentation for a full description.
        public void InsertTextAtSelection(UnsafeNativeMethods.InsertAtSelectionFlags flags, char[] text, int cch, out int startIndex, out int endIndex, out UnsafeNativeMethods.TS_TEXTCHANGE change)
        {
            ITextPointer startNavigator;
            ITextPointer endNavigator;
            int selectionStartIndex;
            int selectionEndIndex;

            startIndex = -1;
            endIndex = -1;

            change.start = 0;
            change.oldEnd = 0;
            change.newEnd = 0;

            if (IsReadOnly)
            {
                throw new COMException(SR.Get(SRID.TextStore_TS_E_READONLY), UnsafeNativeMethods.TS_E_READONLY);
            }

            //
            // 






            ITextRange range = new TextRange(this.TextSelection.AnchorPosition, this.TextSelection.MovingPosition);
            range.ApplyTypingHeuristics(false /* overType */);

            ITextPointer start;
            ITextPointer end;

            GetAdjustedSelection(range.Start, range.End, out start, out end);

            // Someone might change the default selection gravity, so use our
            // own TextPositions to track the insert.
            startNavigator = start.CreatePointer();
            startNavigator.SetLogicalDirection(LogicalDirection.Backward);
            endNavigator = end.CreatePointer();
            endNavigator.SetLogicalDirection(LogicalDirection.Forward);

            selectionStartIndex = startNavigator.CharOffset;
            selectionEndIndex = endNavigator.CharOffset;

            // Do the insert.
            if ((flags & UnsafeNativeMethods.InsertAtSelectionFlags.TS_IAS_QUERYONLY) == 0)
            {
                // Opene a composition undo unit for the composition undo.
                CompositionParentUndoUnit unit = OpenCompositionUndoUnit();
                UndoCloseAction undoCloseAction = UndoCloseAction.Rollback;

                try
                {
                    VerifyTextStoreConsistency();

                    change.oldEnd = selectionEndIndex;

                    string filteredText = FilterCompositionString(new string(text), range.Start.GetOffsetToPosition(range.End)); // does NOT filter MaxLength.
                    if (filteredText == null)
                    {
                        throw new COMException(SR.Get(SRID.TextStore_CompositionRejected), NativeMethods.E_FAIL);
                    }

                    // We still need to call ApplyTypingHeuristics, even though
                    // we already did the work above, because it might need
                    // to spring load formatting.
                    this.TextSelection.ApplyTypingHeuristics(false /* overType */);

                    //Invariant.Assert(this.TextSelection.Start.CompareTo(range.Start) == 0 && this.TextSelection.End.CompareTo(range.End) == 0);
                    // We cannot make this Assertion because TextRange will normalize
                    // differently around Floater/Inline edges.  This is probably
                    // not desired behavior.  To repro,
                    //
                    // <StackPanel xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:sys="clr-namespace:System;assembly=mscorlib" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" >
                    //  <RichTextBox FontSize="24" Height="150">
                    //      <FlowDocument>
                    //          <Paragraph>
                    //              <Run>para</Run>
                    //              <Floater HorizontalAlignment="Right" Width="100" Background="#FFFF0000">
                    //                  <Paragraph><Run>Floater</Run></Paragraph>
                    //              </Floater>
                    //              <Run> </Run>
                    //          </Paragraph>
                    //      </FlowDocument>
                    //  </RichTextBox>
                    // </StackPanel>
                    //
                    // 1. Put the caret before the Floater.
                    // 2. Shift-right to select the entire Floater.
                    // 3. Activate the chinese pinyin IME, and press 'a'.

                    // Avoid calling Select when the selection doesn't need a
                    // final reposition to preserve any spring loaded formatting
                    // from ApplyTypingHeuristics.
                    if (start.CompareTo(this.TextSelection.Start) != 0 ||
                        end.CompareTo(this.TextSelection.End) != 0)
                    {
                        this.TextSelection.Select(start, end);
//.........这里部分代码省略.........
开发者ID:mind0n,项目名称:hive,代码行数:101,代码来源:TextStore.cs


示例17: InsertEmbedded

        // See msdn's ITextStoreACP documentation for a full description.
        public void InsertEmbedded(UnsafeNativeMethods.InsertEmbeddedFlags flags, int startIndex, int endIndex, object obj, out UnsafeNativeMethods.TS_TEXTCHANGE change)
        {
            if (IsReadOnly)
            {
                throw new COMException(SR.Get(SRID.TextStore_TS_E_READONLY), UnsafeNativeMethods.TS_E_READONLY);
            }

            // Disable embedded object temporarily.
#if ENABLE_INK_EMBEDDING
            if (!TextSelection.HasConcreteTextContainer)
            {
                throw new COMException(SR.Get(SRID.TextStore_TS_E_FORMAT), UnsafeNativeMethods.TS_E_FORMAT);
            }

            TextContainer container;
            TextPointer startPosition;
            TextPointer endPosition;
            IComDataObject data;

            // The object must have IOldDataObject internface.
            // The obj param of InsertEmbedded is IDataObject in Win32 definition.
            data = obj as IComDataObject;
            if (data == null)
            {
                throw new COMException(SR.Get(SRID.TextStore_BadObject), NativeMethods.E_INVALIDARG);
            }

            container = (TextContainer)this.TextContainer;

            startPosition = container.CreatePointerAtOffset(startIndex, LogicalDirection.Backward);
            endPosition = container.CreatePointerAtOffset(endIndex, LogicalDirection.Forward);

            InsertEmbeddedAtRange(startPosition, endPosition, data, out change);
#else
            throw new COMException(SR.Get(SRID.TextStore_TS_E_FORMAT), UnsafeNativeMethods.TS_E_FORMAT);
#endif
        }
开发者ID:mind0n,项目名称:hive,代码行数:38,代码来源:TextStore.cs


示例18: FindNextAttrTransition

 // See msdn's ITextStoreACP documentation for a full description.
 public void FindNextAttrTransition(int startIndex, int haltIndex, int count, Guid[] filterAttributes, UnsafeNativeMethods.AttributeFlags flags, out int acpNext, out bool found, out int foundOffset)
 {
     acpNext = 0;
     found = false;
     foundOffset = 0;
 }
开发者ID:mind0n,项目名称:hive,代码行数:7,代码来源:TextStore.cs


示例19: RegisterDragDrop

 public static extern int RegisterDragDrop(HandleRef hwnd, UnsafeNativeMethods.IOleDropTarget target);
开发者ID:JianwenSun,项目名称:cc,代码行数:1,代码来源:UnsafeNativeMethodsCLR.cs


示例20: RetrieveRequestedAttrs

        // See msdn's ITextStoreACP documentation for a full description.
        public void RetrieveRequestedAttrs(int count, UnsafeNativeMethods.TS_ATTRVAL[] attributeVals, out int fetched)
        {
            fetched = 0;
            int i;

            for (i = 0; i < count; i++)
            {
                if (i >= _preparedattributes.Count)
                    break;

                attributeVals[i] = ((UnsafeNativeMethods.TS_ATTRVAL)_preparedattributes[i]);
                fetched++;
            }

            // clear _preparedattributes now so we can keep the ref count of val if it is VT_UNKNOWN.
            _preparedattributes.Clear();
            _preparedattributes = null;
        }
开发者ID:mind0n,项目名称:hive,代码行数:19,代码来源:TextStore.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# LST.BufferChunk类代码示例发布时间:2022-05-26
下一篇:
C# XPath.Query类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap