Pokrewne
- Strona Główna
- Steven Rosefielde, D. Quinn Mil Masters of Illusion, American L
- Masterton Graham Glod (SCAN dal 697)
- Sarah Masters Voices 1 Sugar Strands
- Masterton Graham Podpalacze ludzi t.2 (SCAN dal
- Masterton Graham Dzinn (SCAN dal 1029) (2)
- Masterton Graham Zakleci (SCAN dal 914)
- Masterton Graham Wojownicy Nocy t.1
- Edgar Rice Burroughs Ksiezniczka Marsa (2)
- Krzysztof Karolczak, Współczesny terroryzm w Âświetle teorii Halforda Mackindera
- Cook Robin Zabojcza kuracja by sneer
- zanotowane.pl
- doc.pisz.pl
- pdf.pisz.pl
- pozycb.xlx.pl
[ Pobierz całość w formacie PDF ]
.Using Compound DocumentsCompound documents, or active documents, are Microsoft s names for the technology thatallows in-place editing of a document within another one (for example, a picture in a Worddocument).This is the technology that originated the term OLE, but although it is still inuse, its role is definitely more limited than Microsoft envisioned when it was introduced inCopyright ©2001 SYBEX, Inc., Alameda, CA www.sybex.com2874c20.qxd 7/2/01 4:43 PM Page 877Using Compound Documents 877the early 1990s.Compound documents actually have two different capabilities, object linkingand embedding (hence the term OLE):" Embedding an object in a compound document corresponds to a smart version of thecopy and paste operations you make with the Clipboard.The key difference is that whenyou copy an OLE object from a server application and paste it into a container applica-tion, you copy both the data and some information about the server (its GUID).Thisallows you to activate the server application from within the container to edit the data." Linking an object to a compound document instead copies only a reference to the dataand the information about the server.You generally activate object linking by using theClipboard and making a Paste Link operation.When editing the data in the containerapplication, you ll actually modify the original data, which is stored in a separate file.Because the server program refers to an entire file (only part of which might be linked in theclient document), the server will be activated in a stand-alone window, and it will act upon theentire original file, not just the data you ve copied.When you have an embedded object,instead, the container might support visual (or in-place) editing, which means that you canmodify the object in context, inside the container s main window.The server and containerapplication windows, their menus, and their toolbars are merged automatically, allowing theuser to work within a single window on several different object types and therefore with sev-eral different OLE servers without leaving the window of the container application.Another key difference between embedding and linking is that the data of an embedded objectis stored and managed by the container application.The container saves the embedded object inits own files.By contrast, a linked object physically resides in a separate file, which is handled bythe server exclusively, even if the link refers only to a small portion of the file.In both cases, the container application doesn t have to know how to handle the object andits data not even how to display it without the help of the server.Accordingly, the serverapplication has a lot of work to do, even when you are not editing the data.Container appli-cations often make a copy of the image of an OLE object and use the bitmap to represent thedata, which speeds up some operations with the object itself.The drawback of this approachis that many commercial OLE applications end up with bloated files (because two copies ofthe same data are saved).If you consider this problem along with the relative slowness ofOLE and the amount of work necessary to develop OLE servers, you can understand whythe use of this powerful approach is still somewhat limited, compared with what Microsoftenvisioned a few years ago.Compound document containers can support OLE in varying degrees.You can place anobject in a container by inserting a new object, by pasting or paste-linking one from the Clip-board, by dragging one from another application, and so on.Copyright ©2001 SYBEX, Inc., Alameda, CA www.sybex.com2874c20.qxd 7/2/01 4:43 PM Page 878878 Chapter 20 " From Automation to COM+Once the object is placed inside the container, you can then perform operations on it, usingthe server s available verbs, or actions.Usually the edit verb is the default action the action per-formed when you double-click on the object.For other objects, such as video or sound clips,play is defined as the default action.You can typically see the list of actions supported by thecurrent contained object by right-clicking it.The same information is available in many pro-grams via the Edit ¢' Object menu item, which has a submenu that lists the available verbs forthe current object.NOTEDelphi provides no visual support for building compound document servers.You can alwayswrite a server implementing the proper interfaces.Compound document container support,instead, is easily available through the OleContainer component.The OLE Container ComponentTo create an OLE container application in Delphi, place an OleContainer component in aform.Then select the component and right-click to activate its shortcut menu, which willhave an Insert Object command.When you select this command, Delphi displays the stan-dard OLE Insert Object dialog box.This dialog box allows you to choose from one of theserver applications registered on the computer.Once the OLE object is inserted in the container, the shortcut menu of the control containercomponent will have several more custom menu items.The new menu items include commandsto change the properties of the OLE object, insert another one, copy the existing object, orremove it.The list also includes the verbs, or actions, of the object (such as Edit, Open, or Play).Once you have inserted an OLE object in the container, the corresponding server will launch tolet you edit the new object.As soon as you close the server application, Delphi updates the objectin the container and displays it at design time in the form of the Delphi application you aredeveloping.If you look at the textual description of a form containing a component with an object inside,you ll notice a Dataproperty, which contains the actual data of the OLE object.Although theclient program stores the data of the object, it doesn t know how to handle and show that with-out the help of the proper server (which must be available on the computer where you run theprogram).This means that the OLE object is embedded.To fully support compound documents, a program should provide a menu and a toolbar orpanel.These extra components are important because in-place editing implies a merging ofthe user interface of the client and that of the server program.When the OLE object is acti-vated in place, some of the pull-down menus of the server application s menu bar are addedto the menu bar of the container application.Copyright ©2001 SYBEX, Inc., Alameda, CA www.sybex.com2874c20.qxd 7/2/01 4:43 PM Page 879Using Compound Documents 879OLE menu merging is handled almost automatically by Delphi.You only need to set theproper indexes for the menu items of the container, using the GroupIndex property.Anymenu item with an odd index number is replaced by the corresponding element of the activeOLE object.More specifically, the File (0) and Window (4) pull-down menus belong to thecontainer application.The Edit (1), View (3), and Help (5) pull-down menus (or the groupsof pull-down menus with those indexes) are taken by the OLE server [ Pobierz caÅ‚ość w formacie PDF ]
zanotowane.pl doc.pisz.pl pdf.pisz.pl agnieszka90.opx.pl
.Using Compound DocumentsCompound documents, or active documents, are Microsoft s names for the technology thatallows in-place editing of a document within another one (for example, a picture in a Worddocument).This is the technology that originated the term OLE, but although it is still inuse, its role is definitely more limited than Microsoft envisioned when it was introduced inCopyright ©2001 SYBEX, Inc., Alameda, CA www.sybex.com2874c20.qxd 7/2/01 4:43 PM Page 877Using Compound Documents 877the early 1990s.Compound documents actually have two different capabilities, object linkingand embedding (hence the term OLE):" Embedding an object in a compound document corresponds to a smart version of thecopy and paste operations you make with the Clipboard.The key difference is that whenyou copy an OLE object from a server application and paste it into a container applica-tion, you copy both the data and some information about the server (its GUID).Thisallows you to activate the server application from within the container to edit the data." Linking an object to a compound document instead copies only a reference to the dataand the information about the server.You generally activate object linking by using theClipboard and making a Paste Link operation.When editing the data in the containerapplication, you ll actually modify the original data, which is stored in a separate file.Because the server program refers to an entire file (only part of which might be linked in theclient document), the server will be activated in a stand-alone window, and it will act upon theentire original file, not just the data you ve copied.When you have an embedded object,instead, the container might support visual (or in-place) editing, which means that you canmodify the object in context, inside the container s main window.The server and containerapplication windows, their menus, and their toolbars are merged automatically, allowing theuser to work within a single window on several different object types and therefore with sev-eral different OLE servers without leaving the window of the container application.Another key difference between embedding and linking is that the data of an embedded objectis stored and managed by the container application.The container saves the embedded object inits own files.By contrast, a linked object physically resides in a separate file, which is handled bythe server exclusively, even if the link refers only to a small portion of the file.In both cases, the container application doesn t have to know how to handle the object andits data not even how to display it without the help of the server.Accordingly, the serverapplication has a lot of work to do, even when you are not editing the data.Container appli-cations often make a copy of the image of an OLE object and use the bitmap to represent thedata, which speeds up some operations with the object itself.The drawback of this approachis that many commercial OLE applications end up with bloated files (because two copies ofthe same data are saved).If you consider this problem along with the relative slowness ofOLE and the amount of work necessary to develop OLE servers, you can understand whythe use of this powerful approach is still somewhat limited, compared with what Microsoftenvisioned a few years ago.Compound document containers can support OLE in varying degrees.You can place anobject in a container by inserting a new object, by pasting or paste-linking one from the Clip-board, by dragging one from another application, and so on.Copyright ©2001 SYBEX, Inc., Alameda, CA www.sybex.com2874c20.qxd 7/2/01 4:43 PM Page 878878 Chapter 20 " From Automation to COM+Once the object is placed inside the container, you can then perform operations on it, usingthe server s available verbs, or actions.Usually the edit verb is the default action the action per-formed when you double-click on the object.For other objects, such as video or sound clips,play is defined as the default action.You can typically see the list of actions supported by thecurrent contained object by right-clicking it.The same information is available in many pro-grams via the Edit ¢' Object menu item, which has a submenu that lists the available verbs forthe current object.NOTEDelphi provides no visual support for building compound document servers.You can alwayswrite a server implementing the proper interfaces.Compound document container support,instead, is easily available through the OleContainer component.The OLE Container ComponentTo create an OLE container application in Delphi, place an OleContainer component in aform.Then select the component and right-click to activate its shortcut menu, which willhave an Insert Object command.When you select this command, Delphi displays the stan-dard OLE Insert Object dialog box.This dialog box allows you to choose from one of theserver applications registered on the computer.Once the OLE object is inserted in the container, the shortcut menu of the control containercomponent will have several more custom menu items.The new menu items include commandsto change the properties of the OLE object, insert another one, copy the existing object, orremove it.The list also includes the verbs, or actions, of the object (such as Edit, Open, or Play).Once you have inserted an OLE object in the container, the corresponding server will launch tolet you edit the new object.As soon as you close the server application, Delphi updates the objectin the container and displays it at design time in the form of the Delphi application you aredeveloping.If you look at the textual description of a form containing a component with an object inside,you ll notice a Dataproperty, which contains the actual data of the OLE object.Although theclient program stores the data of the object, it doesn t know how to handle and show that with-out the help of the proper server (which must be available on the computer where you run theprogram).This means that the OLE object is embedded.To fully support compound documents, a program should provide a menu and a toolbar orpanel.These extra components are important because in-place editing implies a merging ofthe user interface of the client and that of the server program.When the OLE object is acti-vated in place, some of the pull-down menus of the server application s menu bar are addedto the menu bar of the container application.Copyright ©2001 SYBEX, Inc., Alameda, CA www.sybex.com2874c20.qxd 7/2/01 4:43 PM Page 879Using Compound Documents 879OLE menu merging is handled almost automatically by Delphi.You only need to set theproper indexes for the menu items of the container, using the GroupIndex property.Anymenu item with an odd index number is replaced by the corresponding element of the activeOLE object.More specifically, the File (0) and Window (4) pull-down menus belong to thecontainer application.The Edit (1), View (3), and Help (5) pull-down menus (or the groupsof pull-down menus with those indexes) are taken by the OLE server [ Pobierz caÅ‚ość w formacie PDF ]