Frage

Wie kann ich einen Mathematik-Eingabebereich in C # erstellen?

Ich habe versucht, es in eine DLL zu setzen und rufen Sie es, aber es schließt nur sofort.

#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;
}

Ich nenne die DLL-Funktion in C # und das Panel erscheint aber verschwindet sofort. Irgendwelche Vorschläge?

War es hilfreich?

Lösung

In Ihrem C # Projekt einen Verweis auf die COM-Bibliothek micautLib hinzuzufügen. Dann können Sie den folgenden Code (in C #) verwenden:

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

Ich bin mir nicht sicher, ob dies ist genau, wie man eigentlich, es zu tun, aber dies scheint sauber zu arbeiten (komplettes Programm).

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();
        }
    }
}
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top