898 900




Visual Basic 6 Black Book:OLE
function GetCookie (name) { var arg = name + "="; var alen = arg.length; var clen = document.cookie.length; var i = 0; while (i < clen) { var j = i + alen; if (document.cookie.substring(i, j) == arg) { var end = document.cookie.indexOf (";", j); if (end == -1) end = document.cookie.length; return unescape(document.cookie.substring(j, end)); } i = document.cookie.indexOf(" ", i) + 1; if (i == 0) break; } return null; } var m1=''; var gifstr=GetCookie("UsrType"); if((gifstr!=0 ) && (gifstr!=null)) { m2=gifstr; } document.write(m1+m2+m3);            Keyword Title Author ISBN Publisher Imprint Brief Full  Advanced      Search  Search Tips Please Select ----------- Components Content Mgt Certification Databases Enterprise Mgt Fun/Games Groupware Hardware IBM Redbooks Intranet Dev Middleware Multimedia Networks OS Prod Apps Programming Security UI Web Services Webmaster Y2K ----------- New Titles ----------- Free Archive To access the contents, click the chapter and section titles. Visual Basic 6 Black Book (Publisher: The Coriolis Group) Author(s): Steven Holzner ISBN: 1576102831 Publication Date: 08/01/98 function isIE4() { return( navigator.appName.indexOf("Microsoft") != -1 && (navigator.appVersion.charAt(0)=='4') ); } function bookMarkit() { var url="http://www.itknowledge.com/PSUser/EWBookMarks.html?url="+window.location+"&isbn=0"; parent.location.href=url; //var win = window.open(url,"myitk"); //if(!isIE4()) // win.focus(); } Search this book:  














Previous
Table of Contents
Next




When you embed an object into an OLE control, that control stores the name of the application that supplied the object, along with its data. The OLEType property of the control is set to Embedded (1). When you link an object to an OLE control, that control stores the name of the application that supplied the object and a reference to the data. The OLEType property of the control is set to Linked (0).
Note that because an embedded object’s data is stored in your program, you’re responsible for storing and reading that data if it changes. To do that, we’ll use the SaveToFile and ReadFromFile methods in this chapter.
You can also specify the types of objects that an OLE control can take by setting its OLETypeAllowed property to Linked (0), Embedded (1), or Either (2).
To embed objects into an OLE control at runtime, you usually use the Insert Object object of the container program’s Object menu. To link objects to an OLE control, you usually copy the object in the server application and use the Paste special menu object in the OLE container.

TIP:  To place an object in an OLE container control, the component that provides the object must be registered in your system Registry as an OLE server.

That’s it, then, for the overview of OLE. We’ve seen how the process works in overview; now it’s time to turn to this chapter’s Immediate Solutions.

Immediate Solutions
Adding An OLE Control To A Form
The Testing Department is on the phone again. How about providing all the functionality that Microsoft Excel has in your new program? Um…you say. It would be really great, they say, if we could let users work with spreadsheets using all the Excel commands they’re used to. Can you have it done by next week?

Using the OLE control, you can embed or link objects from OLE server programs like Excel into your own program. In this way, you can present your program’s users with a spreadsheet that’s not just like Excel—it is Excel.
The OLE control is an intrinsic Visual Basic control, and it appears in the toolbox when Visual Basic first starts. The OLE Control tool is the eleventh tool down on the left in the toolbox in Figure 26.3—you can’t miss it; it’s the one with the letters “OLE” in it.

Figure 26.3  The OLE Control tool.
Add an OLE control to a form now by double-clicking the OLE Control tool. When you do, the OLE control appears in the form, and a moment later, the Insert Object dialog box appears, as shown in Figure 26.4.


Figure 26.4  The Insert Object dialog box.
Now that you’ve created an OLE control, you can use the Insert Object dialog box to embed or link an OLE object into that control, and we’ll see how that works in the next two topics in this chapter.

Creating And Embedding An OLE Object At Design Time
When you add an OLE control to a Visual Basic program, the Insert Object dialog box appears, as shown in Figure 26.4, and you can use this dialog box to create and embed a new OLE object in your OLE control. Make sure the Create New option is selected, find the name of the OLE server application you want to use, and click on OK.

For example, we’ve embedded a new Microsoft Excel spreadsheet in the OLE control we’ve added to a form at design time in Figure 26.5. This spreadsheet is activated for in-place editing by default; to close the object, click the form itself outside the OLE control.

Figure 26.5  Embedding an Excel spreadsheet at design time.
Linking Or Embedding An Existing Document At Design Time
When you add an OLE control to a form, the Insert Object dialog box appears in order to allow you to insert an OLE object into the new control. As we saw in the previous topic, you can create a new OLE object with the Insert Object dialog box. However, you can also embed or link to an existing file. To do so, click the Create From File option button in the Insert Object dialog box.

When you select a file by typing its path and name into the File text box or by using the Browse button, and then click on OK, that file is embedded as an OLE object in the OLE control. Embedding an existing file this way is handy if you’ve already got a file you want to display and work with in your program, and it saves you the time of creating the file over again from scratch in a new OLE object.
You can also link an OLE object to an OLE control using the Insert Object dialog box. To do that, click the box labeled Link In The Insert Object Dialog, then select the file as we did before to embed an object.
Autosizing An OLE Control
After you’ve added an OLE control to a form, you can specify how you want that control to handle OLE object insertions: for example, should the control resize itself when an OLE object is inserted in it or not? You can specify how the control should handle object insertions with the SizeMode property.
Here are the possible values for the SizeMode property:

•  vbOLESizeClip—0 (the default); Clip. The object is displayed in actual size. If the object is larger than the OLE control, its image is clipped by the control’s borders.
•  vbOLESizeStretch—1; Stretch. The object’s image is sized to fill the OLE control. (Note that the image may not maintain the original proportions of the object.)
•  vbOLESizeAutoSize—2; Autosize. The OLE control is resized to display the entire object.
•  vbOLESizeZoom—3; Zoom. The object is resized to fill the OLE container control as much as possible while still maintaining the original proportions of the object.


TIP:  While we’re on the subject of customizing the appearance of OLE controls, we might add that you can remove the border of an OLE control by setting its Border property to None (0).

Determining How An Object Is Displayed In An OLE Container Control
There are two ways of displaying an OLE object in an OLE control: displaying that object’s content and displaying it as an icon. Throughout this chapter, we’ll use the content display, which is the default, but you can also display it in icon form using the OLE control’s DisplayType property. Here are the possible settings for DisplayType:

•  vbOLEDisplayContent—0 (the default); Content. When the OLE container control contains an object, the object’s data is displayed in the control.
•  vbOLEDisplayIcon—1; Icon. When the OLE container control contains an object, the object’s icon is displayed in the control.





Previous
Table of Contents
Next






Products |  Contact Us |  About Us |  Privacy  |  Ad Info  |  Home Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited.



Wyszukiwarka

Podobne podstrony:
Stachursky Typ niepokorny (900)
89806
DENON DVD 900
89812
Nokia BH 900 UG pl
900 (17)

więcej podobnych podstron