Eighth chapter-Object Linking and Embedding (i) (1)

Source: Internet
Author: User
Tags mail ole

Object Linking and embedding (objects linking and embeding) is a set of service features that provide a powerful way to create compound documents from information from different applications. Objects can be almost all types of information, such as text, bitmaps, vector graphics, even voice annotations and video clips.

The writer in the Windows Attachment group is an instance of applying OLE, using the Click Object | Insert menu item, the composer pops up the Insert dialog box, and the dialog box lists several OLE server programs, such as the formula Editing tool, the drawing tool, and the report generation tool. The user double-clicks the left mouse button to activate an OLE server. You can edit an OLE object in the OLE server, and the OLE object appears in the writer document when the user returns to the writer.

Delphi supports OLE technology, Delphi1.0 can create OLE applications, Delphi2.0 can create OLE Automation servers and controller programs. This chapter introduces the basic concepts of object linking and embedding through routines, Delphi's method of creating OLE objects, the concept of OLE Automation, and how to develop OLE Automation servers and controllers.

8.1 OLE Introduction

8.1.1 OLE1.0 and OLE2.0

So far, there are two versions of ole:ole1.0 and OLE2.0. When the user activates the OLE object in the OLE1.0 server, the server program opens its own form in the foreground and gets the focus. The OLE form loses focus and exists in a separate form.

The OLE2.0 server uses the "local" activation method. Local activation means that the Server menu is merged with the Application menu, the status bar of the server is replaced with the application status bar, and the server's toolbar replaces the application tool bar. OLE objects are edited in the application form, but all procedures are handled by the server.

The server that created the OLE object determines how OLE is activated. If a OLE1.0 object is opened in a OLE2.0 compiled application, it will take the OLE1.0 approach.

8.1.2 Links and Embedding

The data for the linked object is saved in the file created by the OLE server, and the embedded object's data is saved in the OLE application.

Linked objects must be saved as files, and only OLE objects that have already been created on the OLE server can be linked to OLE, linked OLE object files can be modified by OLE applications or other programs, and OLE servers and other OLE applications can access and modify OLE objects. Object data is stored in one place, but can be accessed by multiple applications.

The Delphi application can get the latest data in the OLE object file. When OLE Object data is modified by an application, these changes are reflected in all other applications that contain the object.

The embedded object is saved in the OLE application and cannot be accessed by other applications. You can edit an OLE object only if it is activated in an OLE application. Embedded OLE objects do not need to be saved in a file, all data is in the application, which ensures that OLE data is not accidentally deleted or modified. The disadvantage is that the size of the application increases because the OLE data is saved.

If the user wants to save changes to the embedded object, the OLE data can be saved in the file, and the issue will be discussed in detail in section 3rd of this chapter.

Table 8.1 uses the principle of linking or embedding.

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

When to use a link when to use embedded

───────────────────────────────

You want to modify the source object and make changes to the source object, and this

These modifications are reflected in the other with the source on some modifications reflected in a particular should

In a program or text, as in a linked application or text

The source object may be multiple OLE source objects that cannot be an OLE should

Frequently modifying programs with program applications frequently modified

The source object's files are not frequently moved by the source object's files may be moved frequently

And will not be deleted, and will not be deleted

Objects are large, typically through a network or object is small, or objects are large but cannot

e-mail assignments are assigned over a network or e-mail

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

8.1.3 Design state OLE object creation

In Delphi, you can create OLE objects in either the design state or the run State, and table 8.2 illustrates the differences between the two state-created objects.

Table 8.2 Design, run state OLE object creation

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Design state OLE object creation run state OLE object creation

──────────────────────────────────────

object is saved in the run file, adding the desired object to be saved in a file or only at run time

The size of the compiled program reduces the size of the compiler

Developers need to access OLE server developers at design time without having to access the OLE server at design time

The Run-time OLE object has been created, reducing the runtime OLE object has been created, increasing the running

Run time time

OLE object in design run time feasibility edit OLE object can only be edited at run time

The number of OLE objects for the application at design time the application can create a new OLE pair at run time

After the establishment of the elephant

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

In the design state, the OLE server cannot be activated locally and can only be activated within its own form. But in the running state,

This can be used as long as the OLE server supports local activation.

8.1.4 OLE classes, files, projects

The OLE class determines the server where the OLE object is created. Some applications need to create multiple types of OLE objects, such as the application linking or embedding formulas, pictures, and so on. The OLE class also determines the data type that the OLE object contains, and the linked or embedded object defines the OLE class.

An OLE file is a source file that contains OLE Object data. The linked object must use an object file because the linked object is saved in the file. If your application creates an embedded object from an existing source file, you also use the OLE file. For example, if an OLE object that is linked to a quattipro notebook is TUTOR.WBI stored in the D:\DFFICE\QPW directory, the OLE file is D:\DFFICE\QPW\TUTOR. WBI. It is worth noting that OLE files can only be defined for linked objects, but for embedded objects, you simply define OLE classes.

An OLE item is a part of an OLE file that represents a linked or embedded data. You must use an OLE project when your application wants the OLE object to contain blocks of data smaller than the OLE file.

For example, in a Quattipro notebook, OLE objects link gascosts B4 to B5-wide grids, and OLE items are $gascosts; $B $ $B $.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.