Condividi tramite


COMPROP( ) Function

Sets or returns the behavior setting of a COM object property.

COMPROP(oCOMObject, cProperty [, eValue])

Returns

Value of cProperty.

Parameters

  • oComObject
    Specifies a reference to a COM object.
  • cProperty
    Specifies the name of the COM property to set. See the following table for possible values of cProperty:
    cProperty Description
    UTF8 Determines whether UNICODE strings returned from a COM object are converted to ANSI. Conversion is done by default.
    PUTREF Determines if initial object assignment is PROPERTY_PUT (Default) or PROPERTY_PUTREF.
  • eValue
    Specifies the value to apply to the cProperty. Use 0 to specify the default behavior and 1 to use non-default behavior from the description in the previous cProperty table.

Remarks

You must use the complete name of the COM object. If you do not provide eValue, then COMPROP( ) returns the value of cProperty. cProperty is not case sensitive.

Setting an eValue of 1 for UTF8 prevents the display of multi-byte characters as question marks.

Setting an eValue of 1 for PUTREF causes Visual FoxPro to attempt object assignment as a PROPERTY_PUTREF first and, only if that fails, attempt assignment as a PROPERTY_PUT. Object assignments to properties of some ActiveX controls or COM objects requires PROPERTY_PUTREF, and Visual FoxPro defaults to PROPERTY_PUT.

Examples

The following example returns data from methods of an ADO recordset as UNICODE instead of allowing conversion to ANSI:

LOCAL oConn AS adodb.Connection, oRS AS adodb.Recordset
LOCAL lcStr AS STRING
oConn=CREATEOBJECT("ADODB.Connection")
oConn.Open("DSN=Nwind;")  && DSN to SQL Server
oRS=oConn.Execute("select * from customers")
COMPROP(oRS,'UTF8',1)
DO WHILE NOT oRS.Eof
   lcStr = oRS.Fields(4).Value
   oRS.MoveNext
ENDDO
oRS.Close()
oRS.ActiveConnection=NULL
oRS=NULL
oConn.Close()
oConn=NULL

In the following example, an ActiveX control is made to use PROPERTY_PUTREF rather than PROPERTY_PUT:

=COMPROP(oForm.OLECONTROL1, 'PROPERTY_PUTREF',1)

See Also

DBGETPROP( ) Function | COMARRAY( ) Function