首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用C#实现MapInfo自动化

使用C#实现MapInfo自动化
EN

Stack Overflow用户
提问于 2015-03-17 16:32:37
回答 1查看 2K关注 0票数 0

嗨,我正在开发一个解析数据的应用程序,然后我想使用MapInfo在地图上可视化一些数据,我正确地制作了一个MapInfo实例,但到目前为止,我不知道如何在实例上显示数据或如何使用它,我创建的实例即使在可见后也不可见。

下面是我的代码

代码语言:javascript
复制
namespace JA3_Trace_Viewer
{
public partial class JA3Main : Form
{
    public JA3Main()
    {
        InitializeComponent();
    }

    private void JA3Main_Load(object sender, EventArgs e)
    {

        MapInfo.MapInfoApplication mapinfoinstance = new MapInfo.MapInfoApplication();
        mapinfoinstance.Visible = true;
        DDockWindow winM = new DDockWindow();
        winM.Activate();            
    }
}

我想要在地图上可视化的数据是经度和纬度,另一列称为数据,所以如果你能帮我的话。

提前谢谢。

新代码:

代码语言:javascript
复制
    public partial class Form1 : Form
{
    // Sets the parent of a window.
    [DllImport("User32", CharSet = CharSet.Auto, ExactSpelling = true)]
    internal static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndParent);

    //Sets window attributes
    [DllImport("USER32.DLL")]
    public static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);

    //Gets window attributes
    [DllImport("USER32.DLL")]
    public static extern int GetWindowLong(IntPtr hWnd, int nIndex);

    //assorted constants needed
    public static int GWL_STYLE = -16;
    public static int WS_CHILD = 0x40000000; //child window
    public static int WS_BORDER = 0x00800000; //window with border
    public static int WS_DLGFRAME = 0x00400000; //window with double border but no title
    public static int WS_CAPTION= WS_BORDER | WS_DLGFRAME; //window with a title bar
    public static int WS_MAXIMIZE = 0x1000000;

    public Form1()
    {
        InitializeComponent();
    }

    private void button1_Click(object sender, EventArgs e)
    {
        // Create a new instance of MapInfo.
        MapInfoApplication mapinfo = new MapInfoApplication();

        // Get the handle to the whole MapInfo application.
        // 9 = SYS_INFO_MAPINFOWND.
        string handle = mapinfo.Eval("SystemInfo(9)");

        // Convert the handle to an IntPtr type.
        IntPtr oldhandle = new IntPtr(Convert.ToInt32(handle));

        //Make mapinfo visible otherwise it won't show up in our control.
        mapinfo.Visible = true;

        //Set the parent of MapInfo to a picture box on the form.
        SetParent(oldhandle, this.pictureBox1.Handle);

        //Get current window style of MapInfo window
        int style = GetWindowLong(oldhandle, GWL_STYLE);

        //Take current window style and remove WS_CAPTION(title bar) from it
        SetWindowLong(oldhandle, GWL_STYLE, (style & ~WS_CAPTION));

        //Maximize MapInfo so that it fits into our control.
        mapinfo.Do("Set Window 1011 Max");
    }
}
EN

回答 1

Stack Overflow用户

发布于 2015-03-17 22:41:19

MapInfoApplication有一个名为Do()Eval()的方法,您可以在其中传递命令字符串,例如mapinfoinstance.Do('Open Table foo_bar.TAB as foo')

查看MapBasic文件夹中文件夹Samples\DOTNET\...中的MapBasic samples。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/29094419

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档