2015-03-17 1 views
0

Salut Je suis en train de développer une application qui analyse les données puis après je veux visualiser certaines données sur la carte en utilisant MapInfo, j'ai fait une instance MapInfo correctement mais jusqu'à présent je ne sais pas comment afficher les données instance ou comment l'utiliser aussi l'instance que j'ai créée n'est pas visible même après que je l'ai rendue visible.Automatiser MapInfo avec C#

ci-dessous est mon code

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

Les données que je veux visualiser sur la carte est la longitude et la latitude et une autre colonne permet de les appeler des données, donc s'il vous plaît si vous me aider.

Merci d'avance.

Le nouveau code:

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"); 
    } 
} 
+0

Vous n'ouvrez aucune table MapInfo (un fichier '.TAB'), il n'y a donc rien à afficher. –

+0

Dois-je d'abord obtenir la fenêtre mapinfo dans mon formulaire, en fait je pense que la fenêtre mapinfo n'est pas activée dans mon formulaire. –

+0

Non, vous n'obtenez pas un MapInfo intégré complet, avec des barres de menus, etc. Tant que vous n'ouvrez aucune table, vous ne voyez rien. –

Répondre

0

classe MapInfoApplication a une méthode appelée Do() et Eval(), là, vous pouvez passer une chaîne de commande, par exemple Regardez les exemples MapBasic dans le dossier Samples\DOTNET\... dans votre dossier MapBasic.

+0

Salut, merci pour vos commentaires, j'ai ajouté un nouveau code dans le message principal que j'ai utilisé et il ne résout toujours pas le problème, pourriez-vous s'il vous plaît le voir. –