我正在尝试将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)文件如下所示。(删除了一些sub声明。编译成功)
包含"mapbasic.def“
声明方法showMainWindow类"SetNumberLib.InterfaceClass“Lib "SetNumberLib.dll”(ByVal hwnd为整数)
子主干道
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上。有什么线索吗?
发布于 2018-11-22 23:13:42
第二天,当我重新启动Mapinfo时,这种失误行为被证明是错误的。真正的解决方案超出了我的能力范围,但是一个全新的Mapinfo实例可以很好地与.NET集成。
https://stackoverflow.com/questions/53407339
复制相似问题