<i id='ZTr45'><tr id='ZTr45'><dt id='ZTr45'><q id='ZTr45'><span id='ZTr45'><b id='ZTr45'><form id='ZTr45'><ins id='ZTr45'></ins><ul id='ZTr45'></ul><sub id='ZTr45'></sub></form><legend id='ZTr45'></legend><bdo id='ZTr45'><pre id='ZTr45'><center id='ZTr45'></center></pre></bdo></b><th id='ZTr45'></th></span></q></dt></tr></i><div id='ZTr45'><tfoot id='ZTr45'></tfoot><dl id='ZTr45'><fieldset id='ZTr45'></fieldset></dl></div>

  • <legend id='ZTr45'><style id='ZTr45'><dir id='ZTr45'><q id='ZTr45'></q></dir></style></legend>

  • <tfoot id='ZTr45'></tfoot>

        <small id='ZTr45'></small><noframes id='ZTr45'>

          <bdo id='ZTr45'></bdo><ul id='ZTr45'></ul>

        将墨水加载到 C# 中的 MathInputControl

        Load ink to a MathInputControl in C#(将墨水加载到 C# 中的 MathInputControl)
          <tbody id='Rcc8i'></tbody>

        <small id='Rcc8i'></small><noframes id='Rcc8i'>

        <tfoot id='Rcc8i'></tfoot>
        <i id='Rcc8i'><tr id='Rcc8i'><dt id='Rcc8i'><q id='Rcc8i'><span id='Rcc8i'><b id='Rcc8i'><form id='Rcc8i'><ins id='Rcc8i'></ins><ul id='Rcc8i'></ul><sub id='Rcc8i'></sub></form><legend id='Rcc8i'></legend><bdo id='Rcc8i'><pre id='Rcc8i'><center id='Rcc8i'></center></pre></bdo></b><th id='Rcc8i'></th></span></q></dt></tr></i><div id='Rcc8i'><tfoot id='Rcc8i'></tfoot><dl id='Rcc8i'><fieldset id='Rcc8i'></fieldset></dl></div>
          <legend id='Rcc8i'><style id='Rcc8i'><dir id='Rcc8i'><q id='Rcc8i'></q></dir></style></legend>
                  <bdo id='Rcc8i'></bdo><ul id='Rcc8i'></ul>

                • 本文介绍了将墨水加载到 C# 中的 MathInputControl的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在尝试使用 mathinputcontrol 的 LoadInk 方法,但我不知道从哪里创建 IIDispInk 对象,因为它只是一个接口.

                  I'm trying to use use the LoadInk method of an mathinputcontrol but I can't figure out where to create the IIDispInk object from, as it just appears to be an interface.

                  http://msdn.microsoft.com/en-us/library/dd372605(VS.85).aspx

                  任何指导将不胜感激.

                  谢谢:)

                  为清楚起见,这是我到目前为止的代码(感谢 Hans Passant)

                  for clarity, here is my code so far [edit 2: by "so far", I mean of what's been added. Pretty much all the rest of my code can be found on SO under how to create the MIC in C#] (thanks to Hans Passant)

                  MSINKAUTLib.InkDispClass loadInkTest = new MSINKAUTLib.InkDispClass();
                  
                  Stream stream = File.Open("C:\Tim\bytes.isf", FileMode.Open);
                  byte[] bytes = new byte[stream.Length];
                  stream.Read(bytes, 0, bytes.Length);
                  loadInkTest.Load(bytes);
                  
                  
                  ctrl.LoadInk((micautLib.IInkDisp)loadInkTest);
                  

                  不幸的是,这会引发完全相同的异常

                  Unfortunately this throws exactly the same exception

                  灾难性故障(HRESULT 异常:0x8000FFFF (E_UNEXPECTED))

                  C:Timytes.isf 包含从 InkPicture 控件保存的字节,该控件可以加载并保存此文件文件 OK,所以我假设因为 loadInkTest.Load() 方法没有抛出异常(通常它不害羞这样做),它加载数据OK.如果有关于更好(或更明显)获取字节的位置的建议,请告诉我.

                  C:Timytes.isf contain bytes saved from an InkPicture control which loads and saves this file file OK, so I assume that because the loadInkTest.Load() method did not throw an exception (normally it is not shy to do so) that it loaded the data OK. If there is a suggestion on a better (or more obvious) place to get the bytes, please let me know.

                  推荐答案

                  使用项目+添加引用,浏览选项卡.导航到 c:program filescommon filesmicrosoft sharedink 并选择 InkObj.dll.您现在可以创建 MSINKAUTLib.InkDispClass 的实例.它实现了 IInkDisp 并具有 Save 和 Load 方法.

                  Use Project + Add Reference, Browse tab. Navigate to c:program filescommon filesmicrosoft sharedink and select InkObj.dll. You can now create an instance of MSINKAUTLib.InkDispClass. It implements IInkDisp and has Save and Load methods.

                  您必须将对象转换为 micautLib.IInkDisp,接口来自不同的类型库.关键是,在使用 LoadInk() 之前,您必须先调用 MathInputControl 的 Show() 方法.报错很惨,一切都是E_UNEXPECTED.我开始工作的代码:

                  You will have to cast the object to micautLib.IInkDisp, the interfaces come from different type libraries. And the clincher, you have to call the MathInputControl's Show() method first before using LoadInk(). Error reporting is miserable, everything is E_UNEXPECTED. The code I got to work:

                          var ctl = new micautLib.MathInputControl();
                          var ink = new MSINKAUTLib.InkDisp();
                          ink.Load(System.IO.File.ReadAllBytes("c:\temp\test.isf"));
                          var iink = (micautLib.IInkDisp)ink;
                          ctl.Show();
                          ctl.LoadInk(iink);
                  

                  插入和关闭事件的附加事件处理程序.以及将窗户固定在正确位置的胶水.

                  Plus event handlers for the Insert and Close event. And the glue to get the window in the right place.

                  还要注意 micautLib 类型库依赖于机器的位数.麻烦的是 SetOwnerWindow() 方法,您真的想使用它来防止对话框消失在另一个窗口后面.它的参数声明为 LONG_PTR,在 32 位操作系统上为 32 位,在 x64 上为 64 位.窗把手.当您使用 Visual Studio 时,您将始终获得该方法的 32 位版本,因为 VS 是一个 32 位程序.

                  Also beware that the micautLib type library has a dependency on the bit-ness of the machine. The troublemaker is the SetOwnerWindow() method, you really want to use it to prevent the dialog from disappearing behind another window. Its argument is declared as LONG_PTR, a type that is 32-bits on a 32-bit operating system, 64-bits on x64. The window handle. When you use Visual Studio, you will always get the 32-bit version of that method since VS is a 32-bit program.

                  如果您计划支持 64 位操作系统,那么您必须构建一个单独的程序版本.首先运行 64 位版本的 Tlbimp.exe(不是 Visual Studio)来创建互操作包装器.这样参数将是一个 64 位的值,并且与您传递给该方法的窗口句柄兼容.

                  If you plan on supporting 64-bit operating systems then you will have to build a separate version of your program. Starting with running the 64-bit version of Tlbimp.exe (not Visual Studio) to create the interop wrapper. So that the argument will be a 64-bit value and compatible with the window Handle you pass to the method.

                  啊,COM的乐趣.这不是由 Microsoft.Ink.dll 包装的,这并不是真正的意外 :)

                  Ah, the joys of COM. No real accident that this wasn't wrapped by Microsoft.Ink.dll :)

                  这篇关于将墨水加载到 C# 中的 MathInputControl的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Adding and removing users from Active Directory groups in .NET(在 .NET 中的 Active Directory 组中添加和删除用户)
                  set equality in linq(在 linq 中设置相等)
                  HashSet conversion to List(HashSet 转换为 List)
                  How to set timeout for webBrowser navigate event(如何为 webBrowser 导航事件设置超时)
                  Test whether two IEnumerablelt;Tgt; have the same values with the same frequencies(测试两个IEnumerablelt;Tgt;具有相同频率的相同值)
                  How do you determine if two HashSets are equal (by value, not by reference)?(您如何确定两个 HashSet 是否相等(按值,而不是按引用)?)

                      <bdo id='2wUaI'></bdo><ul id='2wUaI'></ul>

                      1. <legend id='2wUaI'><style id='2wUaI'><dir id='2wUaI'><q id='2wUaI'></q></dir></style></legend>

                        <small id='2wUaI'></small><noframes id='2wUaI'>

                            <tbody id='2wUaI'></tbody>
                            <i id='2wUaI'><tr id='2wUaI'><dt id='2wUaI'><q id='2wUaI'><span id='2wUaI'><b id='2wUaI'><form id='2wUaI'><ins id='2wUaI'></ins><ul id='2wUaI'></ul><sub id='2wUaI'></sub></form><legend id='2wUaI'></legend><bdo id='2wUaI'><pre id='2wUaI'><center id='2wUaI'></center></pre></bdo></b><th id='2wUaI'></th></span></q></dt></tr></i><div id='2wUaI'><tfoot id='2wUaI'></tfoot><dl id='2wUaI'><fieldset id='2wUaI'></fieldset></dl></div>
                          • <tfoot id='2wUaI'></tfoot>