试图建立在C#中的数学输入面板 [英] Trying to create a Math Input Panel in C#

查看:636
本文介绍了试图建立在C#中的数学输入面板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何创建在C#中的数学输入面板?

How do I create a Math Input Panel in C#?

我试图把它变成一个DLL和调用它,但它只是关闭的时候了。

I have tried to put it into a dll and call it but it just closes right away.

#include <stdafx.h>
#include <atlbase.h>
#include "micaut.h"
#include "micaut_i.c"

extern "C" __declspec(dllexport) int run()
{
   CComPtr<IMathInputControl> g_spMIC; // Math Input Control
   HRESULT hr = CoInitialize(NULL);
   hr = g_spMIC.CoCreateInstance(CLSID_MathInputControl);
   hr = g_spMIC->EnableExtendedButtons(VARIANT_TRUE);
   hr = g_spMIC->Show();

   return hr;
}



我调用C#DLL函数和面板弹出,但消失的时候了。有什么建议?

I call the dll function in C# and the panel pops up but disappears right away. Any suggestions?

推荐答案

在C#项目中,添加对COM库的引用 micautLib 。然后你可以用下面的代码(在C#):

In your C# project, add a reference to the COM library micautLib. Then you can use the following code (in C#):

MathInputControl ctrl = new MathInputControlClass();
ctrl.EnableExtendedButtons(true);
ctrl.Show();



我不知道如果这正是你应该如何去做,但是这似乎。干净(完整的程序)工作。

I'm not sure if this is exactly how you're supposed to do it, but this seems to work cleanly (complete program).

using System;
using System.Windows.Forms;
using micautLib;

namespace MathInputPanel
{
    static class Program
    {
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            MathInputControl ctrl = new MathInputControlClass();
            ctrl.EnableExtendedButtons(true);
            ctrl.Show();
            ctrl.Close += () => Application.ExitThread();
            Application.Run();
        }
    }
}

这篇关于试图建立在C#中的数学输入面板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆