Based on ArcGIS and Skyline development log 20200801

       I applied for a small topic five years ago-the three-dimensional display of the routing results based on TerraExplorer, which really can't be delayed. I will verify the technical route in these two days.

1. Installation and configuration
       According to the introduction in the previous article, TerraExplorer5.1.3 and TerraBuilder1.7.6 do not need to modify the computer time, and there is no problem in using it, but it cannot be developed. VB, VC and VC#, including ArcGIS VBA, will not work. Trying many methods will not work. Later, after installing TerraExplorer6.5 and TerraBuilder6.5, although the license file has expired, it can be used after the modification time. Don't worry, let's use TE/TB with modified time honestly.
Although ArcGIS 10.2SDK can be installed on VS2013, it still cannot develop addin. The experience of the webmaster is this:

         First of all, encounter such a problem, ValidateAddInXMLTask
error 2 "ValidateAddInXMLTask" task failed unexpectedly.
System.IO.FileNotFoundException: Failed to load the file or assembly "Microsoft.VisualStudio.Shell.11.0, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" or one of its dependencies. The system can not find the file specified.

Warning: Assembly binding logging is turned off.
To enable assembly binding failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There will be some performance penalty associated with assembly binding failure logging.
To turn off this feature, please remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog]. GuanluanView
        downloaded the Microsoft.VisualStudio.Shell.11.0 installation package, which was about 227MB resolved;
       then, another problem occurred, that is, NO GUI components found in this add-in. After trying many methods, I think it may be that ArcGIS 10.2 cannot register addin. Corresponding dll caused, but this is no trick.
      I scratched it from the beginning and found that this addin method is also problematic, and the coupling with arcgis is too high to be suitable. This method is not as good as using VBA. The main problem of VBA is its weak development ability, but it interacts better with ArcMap, as shown below:

ç¹å »æ ¥ çåå¾

 

 2. VBA sends process messages to VC#

VBA code for sending the message "I love programming":

Option Explicit

 Private Type COPYDATASTRUCT

  dwData As Long

  cbData As Long

  lpData As Long

 End Type

 Private Const WM_COPYDATA = &H4A

Private Declare Function FindWindow Lib "user32" Alias _

     "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName _

      As String) As Long

 Private Declare Function SendMessage Lib "user32" Alias _

     "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal _

      wParam As Long, lParam As Any) As Long

  'Copies a block of memory from one location to another.

 Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" _

     (hpvDest As Any, hpvSource As Any, ByVal cbCopy As Long)

 

Private Sub CommandButton1_Click()

Dim cds As COPYDATASTRUCT

   Dim ThWnd As Long

   Dim buf(1 To 1024) As Byte

   Dim a As String, i As Long, lLen As Long

   ' Get the hWnd of the target application

   ThWnd = FindWindow(vbNullString, "Target")

   a$ = "我爱编程" & Format(Now, "yyyy-MM-dd HH:mm:ss") & " !"

   ' Copy the string into a byte array, converting it to ASCII

   lLen = LenB(StrConv(a, vbFromUnicode))

   Call CopyMemory (buf (1), ByVal a, lLen)

   cds.dwData = 3

   cds.cbData = lLen + 1

   cds.lpData = VarPtr(buf(1))

   i = SendMessage(ThWnd, WM_COPYDATA, ThisDocument.Parent.hwnd, cds)

End Sub

 

Private Sub UserForm_Initialize()

' This gives you visibility that the target app is running

 ' and you are pointing to the correct hWnd

   Me.Caption = Hex$(FindWindow(vbNullString, "Target"))

End Sub

 

VC# code of Form1.cs that receives the message

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Windows.Forms;

using System.Runtime.InteropServices;

 

namespace WindowsFormsApplication1

{

    public partial class Form1 : Form

    {

        public Form1()

        {

            InitializeComponent();

            this.Text = "Target";

        }

 

        protected override void DefWndProc(ref Message m)

        {

            switch (m.Msg)

            {

                case WM_COPYDATA:

                    COPYDATASTRUCT cdata = new COPYDATASTRUCT();

                    Type mytype = cdata.GetType();

                    cdata = (COPYDATASTRUCT)m.GetLParam(mytype);

                    this.textBox1.Text = cdata.lpData;

                    break;

                default:

                    base.DefWndProc(ref m);

                    break;

            }

        }

        // The main purpose of the WM_COPYDATA message is to allow read-only data to be passed between processes.

        private const int WM_COPYDATA = 0x004A;

        // Windows by WM_COPYDATA during passing messages do not provide inheritance synchronous mode.

        // Among them , the hexadecimal number corresponding to WM_COPYDATA is 0x004A

        public struct COPYDATASTRUCT

        {

            public  int  dwData;

            public  int  cbData;

            [MarshalAs(UnmanagedType.LPStr)]

            public  string  lpData;

        }

 

    }

}

The result chart is as follows:

 æ æ is ¢ 2.png

For more information, see xiaok marine surveying and mapping network and the public account of the same name

Guess you like

Origin blog.csdn.net/u011115875/article/details/108030024