首页 > 解决方案 > 使用 TextBox 控件将 MapBasic 与 .NET 问题集成

问题描述

我正在尝试将 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 Class "SetNumberLib.InterfaceClass" Lib "SetNumberLib.dll" (ByVal hwnd As Integer)

子主

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

结束子

子显示窗口

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

结束子

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

任何帮助将不胜感激。

新信息:RichTextBOX 工作正常。问题仍然在于文本框。有什么线索吗?

标签: c#.netmap-basic

解决方案


事实证明,当我重新启动 Mapinfo 时,这种错过行为在第二天就停止了。真正的解决方案超出了我的掌握,但是一个新的 Mapinfo 实例与 .NET 集成得很好。


推荐阅读