Tutorials to .com

Tutorials to .com » Database » Foxpro » Foxpro OLE control

Foxpro OLE control

Print View , by: iSee ,Total views: 34 ,Word Count: 1708 ,Date: Fri, 17 Apr 2009 Time: 12:37 AM

OLE control is what foreignfirst explain OLE, it is the English "Object Link and Enbed" acronym, which means Object Linking and Embedding.

The object here, and we have previously said the curriculum is different and the object, not the form, text box or something like that, but other than vfp things, such as a picture, a sound, an EXCEL chart, a WORD document and so on, I know you must be very excited about this: Is it true that the process of VFP Add these things can it? My software does not have a multi-media functions, it would mean that.

Yes, indeed it is, here we will tell you what to do.

First, general field

VFP data table there is a general-purpose field, you can take a variety of other formats, such as pictures, sounds and so on, here is the way Add the OLE.

Add other documents will be order generic field is:

APPEND GENERAL General Field Name
[FROM file name]

For example, we can give the Personnel Data Sheet file (rsda.dbf) plus a field, "photos" to a person's photo with a good scanner, scan to file name "crops. Bmp" stored in the current directory, open the data sheet rsda will record pointer go "crops" of this record, and then perform the following command on the crops of the photos can be placed on the record: the

append general photos from crops. bmp

Specific to the program can add and modify the form of staff to add a text box, enter the picture in which the file name in the text box to add the event lostfocus the following code:

zpwjm = alltrim (this.value) & & the text box contents into a variable
if file (zpwjm) & & If the file exists
append general photos from & zpwjm & & file Add photos field
else & & Otherwise
messagebox ( "File name does not exist!", 64, "Note") & & give prompt

Such as to delete the contents of general-purpose field that can be used the following statement:

General append general field names

Learn one stroke

Can also be interactive document Add to common fields:
  1. State in the browser, place your cursor on the general field, in accordance with "ctrl + pagedown" button, or double-click on the field, the emergence of a form, in Figure 1;
  2. Call menu "Edit / Insert Object" in Figure 2;
  3. In the resulting dialog box, select the "Create from File";
  4. Enter the file name and determine, you can show the common fields in the form of the document to see the insert;
  5. To close the form.

To modify the contents of general-purpose field, you can double-click the Step 2 to see the object.

If you want to delete the contents of general-purpose field, the pace can be used in section 2, "Edit / Clear."

In Step 3, you can also select "New" then choose the object type, such as WORD, and then you can enter an article, then stored in the generic field.

With GM field contents can be seen in the browser field to display "Gen", in capital letters at the beginning, or at the beginning is lowercase.

Second, Linking and Embedding

Linking and Embedding is the two concepts, that is to say we will be outside the VFP Add VFP object, the link can be used in a way which can be embedded in the way that they have any different?

Embed: refers to the real object placed in VFP, or is put to a copy. Advantage of the data source if it is lost, it still; disadvantage is that the data source has changed, then it will not change, such as photos for a data table does not automatically replace the photos, unless the call to re-order to join us in. Another drawback is that will become very large table.

Link: Add the real object does not VFP, but only put addresses into each depends on, it get to this address. Clearly, with its advantages and disadvantages of embedding is just the opposite.

On the first point, we are embedding used, if you want to link, append general with the "link" clause; interactive, if the document is created in the dialog box, select the "link", if it is new, because it is directly the establishment of a common field in the document, what the data source does not exist, it must be embedded.

Third, OLE control bound type

The so-called "binding", that is, the control is tied with the general field of the (if do not see why the meaning of common field), that is to say it is a generic data source content field, we can OLE bind a control on the form type in order to show the contents of general-purpose field, methods for:

  1. Into the form designer;
  2. OLE bound control transfer type tool wpe4.jpg (974 bytes) ;
  3. Place in a form appropriate to draw the control, as an image control settings as in Figure 3;
  4. Controlsource set its properties as a general field of field names, for example, "rsda. Photos", in Figure 4.

When running the form, we will be able to see the effect of, and when the table record pointer moves, the form will also be changes in the photos.

Fourth, OLE container type controls

Similar to those in the general field Add the object, when called on the toolbar type OLE container control tools, in the form out of the control will be a common field in a similar dialog box to insert the object, insert ways in the same general field, which is directly inserted into the form of objects rather than as binding controls to a generic type to get the field.

And in the general field of the Insert Object dialog box when it is different, that is, more than a "Insert Control", in Figure 5, which is used to insert ActiveX controls, ActiveX controls on high-level course to talk about it anymore, and this a lesson in this Bye-Bye.

Fifth, an important means of procedures

OLE controls are an important method of procedure is doverb, call the method can be inserted into the host object (such as general computer hosts BMP format procedure is brush), on the object for editing, running and so on.


Object. DoVerb [action parameters]

Action parameters

OLE instructions for how to move objects. If you omit the parameters, the host will be the implementation of procedures and call the object, such as a BMP image, and on procedures to call the brush open the image, similar in form, double-click the OLE object. [AutoPage]

The following actions as the standard parameters:

Parameter values Action
0 The implementation of the implied action.
-1 Open the object for editing. If the program is to support the activation at the scene, the object can be opened in the form, such as WODR, EXCEL etc..
-2 In another window object.
-3 If it is embedded in the object, start the object, and hide the host program. This is very useful, such as the form is to embed a sound file, this parameter can be used to start the voice of players (such as tape recorders), audio player, but did not show tape recorder.
-4 If the object activation support the scene, then the object will be activated at the scene, and display user interface. If the object does not support the site activation, will produce an error.
-5 If we focus on the OLE control, it will open a window to make the object editable. If the object does not support the click to activate, it will generate an error.
-6 If the object has entered the edit mode, this parameter can be used to abandon the changes made.

The following are examples of how to use this method:

You can form into a binding-type OLE control, the data source for the table of a common field, the contents of the field for the voice, such as personnel files can be described in a speech of self-recording, added to the form Add a button, the button write the following statement:

thisoform.oleboundcontrol1.doverb (-3)

Press this button so you can record the voices of the current released and will not be shown to play a sound software.

FoxPro Tutorial Articles

Can't Find What You're Looking For?

Rating: Not yet rated


No comments posted.