使用TextBox控件将MapBasic与.NET问题集成

时间:2018-11-21 07:43:46

标签: c# .net map-basic

我正在尝试将Map-Basic与.NET集成 最终目标是获得一个能够设置地址号码的应用,以友好,自动化的方式进行细分 我的问题是.NET表单中的TextBoxes根本没有响应。他们甚至没有获得初始值。 这是一个简化的示例代码。

Form1.Designer.cs

partial class Form1
{
    private System.ComponentModel.IContainer components = null;

    protected override void Dispose(bool disposing)
    {
        if (disposing && (components != null))
        {
            components.Dispose();
        }
        base.Dispose(disposing);
    }

    private void InitializeComponent()
    {
        this.textBox1 = new System.Windows.Forms.TextBox();
        this.button1 = new System.Windows.Forms.Button();
        this.SuspendLayout();
        // 
        // textBox1
        // 
        this.textBox1.Location = new System.Drawing.Point(68, 67);
        this.textBox1.Name = "textBox1";
        this.textBox1.Size = new System.Drawing.Size(255, 26);
        this.textBox1.TabIndex = 0;
        this.textBox1.TabStop = false;
        this.textBox1.Text = "Initial text";
        // 
        // button1
        // 
        this.button1.Location = new System.Drawing.Point(68, 184);
        this.button1.Name = "button1";
        this.button1.Size = new System.Drawing.Size(255, 56);
        this.button1.TabIndex = 1;
        this.button1.Text = "button1";
        this.button1.UseVisualStyleBackColor = true;
        this.button1.Click += new System.EventHandler(this.button1_Click);
        // 
        // Form1
        // 
        this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F);
        this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
        this.ClientSize = new System.Drawing.Size(800, 450);
        this.Controls.Add(this.button1);
        this.Controls.Add(this.textBox1);
        this.Name = "Form1";
        this.Text = "Form1";
        this.ResumeLayout(false);
        this.PerformLayout();

    }

    public System.Windows.Forms.TextBox textBox1;
    private Button button1;
}

这是Form1.cs

public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
    }
    private void button1_Click(object sender, EventArgs e)
    {
        MessageBox.Show("Click");
    }
}

最后是带有静态方法的类

public class InterfaceClass
{
    static Form1 form;
    public static void showMainWindow(int hwnd)
    {
        form = new Form1();
        form.Show();
        form.PerformLayout();
    }
}

我的MB(MapBasic)文件如下所示。 (删除了一些子声明。编译成功)

包含“ mapbasic.def”

声明方法showMainWindow类“ SetNumberLib.InterfaceClass”库“ SetNumberLib.dll”(ByVal将其作为整数)

子主要

Create Menu "Map Numbering" As
    "Show Window" Calling ShowWindow,
    "Exit" Calling EndApp
Alter Menu bar Add "Map Numbering"

结束子

子ShowWindow

Dim hwndPro As Integer
hwndPro = SystemInfo(SYS_INFO_MAPINFOWND)
Call showMainWindow(hwndPro)

结束子

返回表格。按钮工作正常。单击时显示消息框 文本框就像一个无反应的图片。更差。我怀疑它会重绘。 任何想法? 我错过了什么吗? 顺便说说。当我从Net App测试dll时,文本框可以正常工作。

我们将不胜感激任何帮助。

新信息: RichTextBOx正常工作。问题仍然在于TextBoxes。 有任何线索吗?

1 个答案:

答案 0 :(得分:0)

事实证明,第二天重新启动Mapinfo时,这种未命中行为受阻。 真正的解决方案超出了我的掌控,但是一个新的Mapinfo实例可以与.NET很好地集成。