ComProp()

ComProp() is a function added in VFP 7 that allows you to change certain properties of a COM object after it's been instantiated. The two properties that can be changed are UTF8, which determines whether UNICODE strings are converted to ANSI, and PUTREF, which determines how VFP assigns the COM object's properties: by reference or by value.

Usage

nReturnValue = ComProp( oComObject, cProperty [, nValue ] )

Parameter

Value

Meaning

oComObject

Object

The COM object reference.

cProperty

"UTF8"

The property that determines whether UNICODE strings are converted to ANSI. By default, they are.

"PUTREF"

The property that determines whether the object's properties are assigned by PROPERTY_PUTREF or PROPERTY_PUT. PROPERTY_PUT is the default.

nValue

Omitted

Returns the current value of the property specified in cProperty.

0

Sets the property specified in cProperty to the default value.

1

Sets the property specified in cProperty to the non-default value.

nReturnValue

Numeric

Returns the new value of the specified property.


The UTF8 property determines whether strings are converted to ANSI. When double-byte character strings are converted to ANSI, they display as question marks. Set UTF8 to 1 to prevent this.By default, Visual FoxPro to attempts to assign the object reference as PROPERTY_PUT. However, some ActiveX or COM objects require PROPERTY_PUTREF. By setting cProperty to "PUTREF", VFP attempts to assign the object reference as a PROPERTY_PUTREF first, but if it fails, VFP attempts assignment as a PROPERTY_PUT. This allows you to use controls that require assignment as PROPERTY_PUTREF.The Help file has an excellent example for the UTF8 property.

This one's a documentation bug: The Help file shows the example for setting the PUTREF property by spelling out PROPERTY_PUTREF. It should be PUTREF, instead.


Example

* Turn off UNICODE conversion to ANSI.
= ComProp(oRecordSet, "UTF8", 1)
 
* Specify that VFP assign the object reference as  
* PROPERTY_PUTREF.
= ComProp(oMyForm.OleControl1, "PUTREF", 1)

See Also

ComArray(), CreateObject(), CreateObjectEx()


Back to Table of Contents

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