OLE Automation Technology in Delphi and MapInfo Integrated Map Development

Application of OLE Automation Technology in Delphi and MapInfo Integrated Map Development

Abstract: This paper discusses the integration of MapInfo maps using OLE automation technology and visual programming tool Delphi, and introduces the method of integrating maps and message callback to MapInfo through routines. Thereby achieving
MapInfo is integrated into the Delphi application system to achieve efficient development of application GIS (Geographic Information System) software.
Key words: geographic information system; OLE; MapInfo; Delphi; callback

The ApplicaTIon Of OLE AutomaTIon Technology In Map-integraTIon Between Delphi And MapInfo TONG Gang, SHEN Qing-hua, BI Wei-zhun (College of AutomaTIon and Electronic, Qingdao University of Science and Technology, Qingdao 266042, China)
Abstract: The method of realizing map-integration between Delphi and MapInfo using OLE automation technology is discussed, and the method of Map Integration and the Callbacks of MapInfo message is also introduced with example in this article. So MapInfo is integrated in application of Delphi to Develop efficiently applied GIS(Geographical Information System).
Key words: GIS; OLE; MapInfo; Delphi; Callbacks
1 Introduction In the Windows system, there are two main methods of MapInfo secondary development, that is, using the development tools that they bring.
MapBasic and use excellent development tools such as Delphi, VC. Programs developed with the development tools such as MapBasic must run in the MapInfo environment. The system resources are expensive, the development efficiency is not high, and the functions are not strong.
It is difficult to develop a user-friendly and powerful custom program, which is more suitable for extending the functionality of MapInfo. Using the excellent development tools such as Delphi for secondary development, the background processing of the map still uses MapInfo support software, but because the front desk uses professional development tools such as Delphi, in terms of development efficiency, development capabilities, localization, portability, etc. Better than the built-in tools, and can continue to develop with the development of the entire software development industry [1]. The key to this approach is the combination of the front-end custom program and the back-end MapInfo. Currently, there are mainly OLE Automation and development using MapX standard components.
Delphi is an object-oriented visualization software development tool of INPRISE, USA, with very powerful functions.
It can quickly and efficiently develop various programs based on Windows environment, especially in interface design and database programming. Object-oriented and visual design is its most outstanding advantage. At the same time, it has powerful compiling ability, which greatly improves the execution efficiency of the program and becomes a development tool for many programmers.
2 OLE automation technology
OLE (Object Linking and Embedding) is a set of protocols and functions proposed by Atduscorporation of the United States.
The purpose is to simplify the creation and maintenance of composite files. It is the most complex subsystem in Microsoft Windows systems and a form of interprocess communication. The so-called object link refers to a composite file containing a reference pointer to other applications, connecting Windows applications through OLE.
With this OLE technology that enables users to share different application information resources, it is easy to integrate various applications. OLE Automation is an interactive process communication mechanism designed for WINDOWS. It allows mutual access between different applications. It allows one application to access another application or DLL (dynamic link library), such as creating EXCEL in Delphi. Tables and so on, and access to methods and properties of these application objects
(Property), which overcomes the shortcomings of linking and nesting, that is, the object can not be controlled by programming means, and the programmatic control of OLE components is realized. OLE Automation consists of two parts: an application that exposes the OLE components to control, called an OLE Automation server; and another that utilizes the components provided by the OLE server.
The application that controls the object is called an OLE client. Due to the small size of the OLE Automation server, the stability and development and maintenance of the program are superior to the traditional large programs. For each OLE object's properties and methods, the programmer can decide to express some properties and methods of the OLE Automation server through OLE automation, while the private object is invisible to external users, but OLE client programmers only need Knowing the name of the application containing the object, the name of the object's class, and the name of the property and method you want to use, you can use the Automation server [3]. Through OLE automation technology, the Delphi language can be easily used for map integration. At this time, the Delphi program is the client program.
3 Using OLE automation technology to achieve map integration When Delphi and MapInfo are integrated, you can use Delphi as the control or DDE of OLE automation.
Customers, running MapInfo in the background, but it is best to use OLE automation because this way is better than DDE
The way is faster, more reliable, and you can get more error messages during the debug run. OLE Automation is a technology that interoperates between Windows programs, creating automated client programs to manipulate other programs, while MapInfo can be used as
The OLE object server and provides a corresponding set of methods.
3.1 Implementing Delphi to obtain control and service for MapInfo Professional
In the Delphi program, the corresponding interface method function is executed through a specific ActiveX control interface, MapInfo
Professional issues control commands to get its services and manipulates the MapInfo graphics embedded in the Delphi program interface. For this technology point, you can use Delphi to activate and control the functions supported by ActiveX (OLE).
MapInfo Professional runs. OLE automation is a technique for interoperating between Windows programs. Delphi fully supports OLE automation operations, can create automated client programs to operate other programs, and MapInfo can be used as a server for OLE objects, and provides a corresponding set of methods, Delphi Create a client automation program by creating an OLE object. To create an OLE object, call the CreateOLE-Object function (defined in the comObj unit).
And the result is assigned to a variable of type Variant, through which the program will access the OLE object.
At this time, the Delphi program is an ActiveX (OLE) client application that controls MapInfo Professional to run. MapInfo Professional running in the background is an ActiveX (OLE) automation server that provides services for Delphi programs.
The combination of Delphi and MapInfo Professional is shown in Figure 1.

Figure 1 How Delphi and MapInfo Professional are combined

Fig.1 Combination of MapInfo Professional and Delphi
3.2 Integration of Delphi application and MapInfo (1) Establishing MapInfo automation object
Delphi creates a client automation program by creating an OLE object. To create an OLE object, you need to call the CreateOLEObject function (defined in the OLEAUTO unit) and assign the result to a Variant-type variable. The program passes this variable later. To access OLE objects. Let the variable name Olemapinfo, the specific statement is as follows:
Var OleMapInfo:Variant;//Declare variables of type OLE Variant in Delphi applications
Olemapinfo:=CreateOleobject('mapinfo.application');//Create an OLE object
(2) Integration of MapInfo window in Delphi application
After the Ole automation object is created, the background MapInfo is successfully started, and the Do method of the object can be used to MapInfo.
Send a command such as:
Olemapinfo.do('set application window '+winhand);
Olemapinfo.do('set next document parent'+winhand+'style l');//Relocate the MapInfo file window, which can also be used to relocate other special windows or legends, using MapBasic's "setwindow" statement;
"style1" can also be "style2" or "style3", which indicates the type of window created.
After completing the above settings, you can open the MapInfo file in the client program, such as:
Olemapinfo.do ('open table"city.tab"');
Olemapinfo.do ('map from city ');//Open the MapInfo table to directly call the MapInfo menu or button command to operate on the map window, just call MapInfo
The RunMenuCommand method, which preserves the functionality of the standard MapInfo button, greatly reduces the difficulty of reprogramming and makes it easy to implement the basic functionality of MapInfo. The specific statement is as follows:
Olemapinfo.runmenucommand(1705);//Zoom in
Olemapinfo.runmenucommand(1706);//Reduce
Olemapinfo.runmenucommand(1702);//Roaming
(3) Terminating the MapInfo program When calling Delphi's CreateOleObject0 function to create a new MapInfo event, the MapInfo event is terminated when the object variable is released. When the object variable is a local variable, when the local process is exited, When,
The MapInfo event is released. If it is a global variable, it must be assigned "Unassigned" to be released. The statement is as follows: Olemapinfo:=Unassigned; / / release the global variable, terminate the MapInfo program Application.Terminate; / / terminate the Delphi program
3.3 Implementation of MapInfo CallBack in Delphi By setting the integrated map program, MapInfo can automatically send information to the client program. This type of flag information, that is, the event causes MapInfo to call the client program. This kind of message is called callback.

To use callbacks, the client program must be able to act as an OLE Automation server, and Delphi can be easily implemented.
The implementation principle is shown in Figure 2:

Figure 2 Schematic diagram of implementing MapInfo callback in Delphi
Fig.2 The schematic diagram of realizing callback of MapInfo in Delphi
To implement CallBack for MapInfo, there are generally the following steps:
1) Create a class that defines several OLE methods. If you want to get the content on the status bar of MapInfo,
Then create the SetStatusText method (with a string parameter); if you want to get the ID number of the map window that has changed,
Then create the Windowcontentschanged method (with an integer parameter);
2) Create an object for the class defined in 1);
3) After confirming that MapInfo has been started, call MapInfo's SetCallBack method to register the OLE Automation object in the "receiver" of the message sent by MapInfo;
4) Customize menus or buttons through which the methods defined in 1) are called.
When an event occurs in MapInfo, MapInfo organizes the corresponding information into a form that is passed to the client application as a method parameter. Inside these methods, the programmer can process this information and extract the required information. Take the status bar of the custom client as an example. The callback is used as follows:
1) Create a class that defines the SetStatusText method. This method takes a parameter StatusText of type WideString.
This parameter is passed to MapInfo by the client.
Select File|New|ActiveX|Automation Object in Delphi6.0 to start Automation
The Object wizard opens the "Type Library" editor. This assumes that the class created is named TmyCallBack.
2) Add a status bar to the application form.
3) Create an object using the class defined in the first step.
varCallBack := TMyCallBack.Create;
4) Call the SetCallBack method of the automatic OLE object to pass the parameters.
oleMapInfo.SetCallback(varCallBack As IMyCallBack);
5) Process the StatusText parameter passed by MapInfo in the SetStatusText method to control the display of the status bar.
Procedure TMyCallBack.SetStatusText(const StatusText: WideString);
Begin MainForm.StatusBar1.Panels[0].Text := StatusText;
//MainForm is the form that holds the map component, StatusBar1 is the default name for adding the status bar, and panel is used to display the content on the status bar of MapInfo; End;
4 Conclusion Using OLE automation technology, the secondary development of MapInfo is realized by Delphi, and Delphi is fully utilized.
The powerful database programming capabilities of programming tools and the graphics processing power of MapInfo Professional. In the development process,
The two are independent of each other. Delphi can easily call MapBasic code without any changes, and realize the function and effect of MapInfo Professional by submitting control commands through simple OLE automation technology, and achieve good application results. At the same time, in the MapInfo message callback processing method, you can also use OLE automation technology to
Automatic callback messages for MapInfo Professional.

Coupletech Co., Ltd. is a manufacturer of professional Q-switches and Modulators. We have integrated fabrication technologies, endless perfection, unending innovation for product quality. Besides, we also offer special need For custom design. Here you will find information on a wide range of electro optic and passive optical components such as Pockels cells, Q-switches, electro-optic phase and amplitude modulators.

Coupletech could supply a variety of different types of longitudinal and transverse Pockels cells  for Q-switching, modulation, pulse picking. e.g. BBO Q-Switch ( BBO Pockels Cell ), DKDP Q-Switch ( DKDP Pockels cell ), LN Q-Switch ( LN Pockels cell ), RTP Q-Switch ( RTP Pockels cell ), KTP Q-Switch (KTP Pockels cell). and so on.


Pockels Cell

Electro-optic Components, BBO Pockels Cells, LN Pockels Cells, KTP Pockels Cells, DKDP Pockels Cells, EO Q-Switches, LGS Pockels Cells, RTP Pockels Cells

Coupletech Co., Ltd. , http://www.coupletech.com