OLEBoundControl, OLEControl

These controls are containers for all sorts of interesting objects—sounds, pictures, graphs, cartoons, video clips—whatever you can find an OLE Server to work with. They are very similar, with the major difference that the OLEBoundControl stores its data in a Visual FoxPro general field.

Property

Value

Purpose

AutoActivate

Numeric

Determines how the object can be activated: It can be set so the object can be activated only programmatically, or each time the object receives the focus. By default, the object is activated only if it's double-clicked.

AutoSize

Logical

Determines whether the container—the VFP portion of the control—resizes to fit the area the OLE Control wants to take up. By default, AutoSize is .F. and the developer specifies the size of the control on the form.

ControlSource

(Bound control only)

Character

The field with which the control is associated. Must be a General field.

DocumentFile

Character

Contains the origin of the linked data. Blank if the data is embedded. Read-only.

HostName

Character

The window title to use when an object is edited in its own window. A character string you can supply with your own application's name rather than the feeble "Object from FoxPro 283839" message we had in 2.x.

Object

Object

An object reference to the contained object itself. Allows the properties and methods of the OLE Server to be accessed and manipulated.

OLEClass

Character

The server the data belongs to. Read-only at runtime and design-time, this can be specified only when the class is created in code or by using the APPEND GENERAL command on the underlying field.

OLETypeAllowed

Numeric (0,1, and 2)

This property tells whether there is any data associated with the OLE Control, and whether the associated object is an OCX, embedded data, or linked data.

Sizable

Logical

Determines whether the OLE object can be resized within the control. If the control's AutoSize is set to .T., the entire container and contents can be made a different size. If only this property is true, the view of the OLE object is magnified or shrunk within a fixed frame.


Event

Purpose

DoVerb

Activates the object in a number of different ways.


The two types of OLE controls are windows into other applications. We can use their properties to control the presentation and capabilities of that other application. The primary difference between the two is that the OLEBoundControl changes to reflect record-specific data, since the data is associated with a FoxPro field.

Example

* Create a general field record for a bound control.
CREATE CURSOR temp (genlfield G)
APPEND BLANK
* Add a picture - the "class" to use depends on your
* Windows installation - this is for Win95.
APPEND GENERAL genlfield ;
  FROM _SAMPLES + "Tastrade\Bitmaps\ttradesm.bmp" ;
  CLASS "Paint.Picture"
* Create a form with a bound control.
oForm=CREATEOBJECT("form")
oForm.AddObject("olbPic","OLEBoundControl")
* Size the control to a decent size.
oForm.olbPic.Width = .9 * oForm.Width
oForm.olbPic.Height = .9 * oForm.Height
* Point it to the data source and display the form.
oForm.olbPic.ControlSource = "Temp.GenlField"
oForm.olbPic.Visible = .t.
oForm.show()
 
* Create an unbound control, and manipulate it via
* OLE Automation.
oForm = CREATEOBJECT("DemoForm")
oForm.AddObject("oleCalendar","oleCalendar")
oForm.oleCalendar.Resize()  && fill the form
oForm.oleCalendar.Visible = .T.  && display it
WITH oForm.oleCalendar.Object
  .ShowTitle = -1 
  .TitleFontColor = RGB(128,0,128)
  .TitleFont.Name = "Times New Roman"
  .TitleFont.Size = 14
  .TitleFont.Italic = .T.
ENDWITH
oForm.Show()
READ EVENTS  && Wait here until form is destroyed.
 
DEFINE CLASS DemoForm AS Form
  PROCEDURE DESTROY
    CLEAR EVENTS
  ENDPROC
ENDDEFINE
 
DEFINE CLASS oleCalendar AS OLEControl
  OLEClass = "MsCal.Calendar"
  PROCEDURE ReSize
    This.Width = ThisForm.Width * 0.9
    This.Height = ThisForm.Height * .9
  ENDPROC
ENDDEFINE

See Also

Append General, AutoActivate, ControlSource, DocumentFile, DoVerb, HostName, Modify General, OLEClass, OLETypeAllowed, Sizable


Back to Table of Contents

Copyright © 2002-2018 by Tamar E. Granor, Ted Roche, Doug Hennig, and Della Martin. Click for license .