Pregunta

¿Cómo creo un Panel de entrada matemática en C #?

He intentado ponerlo en un dll y llamarlo, pero simplemente se cierra de inmediato.

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

Llamo a la función dll en C # y el panel aparece pero desaparece de inmediato. ¿Alguna sugerencia?

¿Fue útil?

Solución

En su proyecto C #, agregue una referencia a la biblioteca COM micautLib . Luego puede usar el siguiente código (en C #):

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

No estoy seguro de si esto es exactamente como se supone que debes hacerlo, pero parece que funciona de manera limpia (programa completo).

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();
        }
    }
}
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top