Integrating MapBasic with .NET Problem with TextBox Controls

151 views Asked by At

I'm trying to integrate Map-Basic with .NET The final goal is to get an app capable to set address numbers to segment in a friendly and automated way The problem I having is that TextBoxes in the .NET form are not responsive at all. They don't even get the initial value. Here is a simplified example code.

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

This is Form1.cs

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

And finally a class with static method

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

My MB (MapBasic) File looks like this. (Having removed some sub declares. It compiles successfully)

Include "mapbasic.def"

Declare Method showMainWindow Class "SetNumberLib.InterfaceClass" Lib "SetNumberLib.dll" (ByVal hwnd As Integer)

Sub Main

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

End Sub

Sub ShowWindow

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

End Sub

Back to the form. The Button works fine. The messagebox is shown when clicked The textbox is like a non reactive picture. Worse. I doubt it gets the redraw. Any idea? Am I missing something. By the way. When I test the dll from a Net App the text-boxes work fine.

Any help will be highly appreciated.

New Info: RichTextBOx Works fine. The problem is still with TextBoxes. Any Clue?

1

There are 1 answers

0
mdev On

It turned out to be that this miss behaviour stooped the next day when I restarted Mapinfo. The real solution is beyond my hands but a fresh Mapinfo instance works fine integrated with .NET.