محاولة لخلق لوحة الإدخال الرياضيات في C #
سؤال
كيف يمكنني إنشاء لوحة الإدخال الرياضيات في C #؟
ولقد حاولت وضعه في ملف DLL والذي يطلق عليه لكن فقط يغلق على الفور.
#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;
}
وأنا استدعاء الدالة DLL في C # و لوحة للملوثات العضوية الثابتة ولكن يختفي على الفور. أي اقتراحات؟
المحلول
في # مشروع C، إضافة إشارة إلى micautLib
مكتبة COM. ثم يمكنك استخدام التعليمات البرمجية التالية (في C #):
MathInputControl ctrl = new MathInputControlClass();
ctrl.EnableExtendedButtons(true);
ctrl.Show();
ولست متأكدا إذا كان هذا هو بالضبط كيف كنت من المفترض أن تفعل ذلك، ولكن يبدو أن هذا العمل نظيفة (البرنامج الكامل).
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();
}
}
}
لا تنتمي إلى StackOverflow