COMPROP( ) Function
Sets or returns the behavior setting of a COM object property.
COMPROP(oCOMObject, cProperty [, eValue])
Parameters
oComObject
Specifies a reference to a COM object. cProperty is not case sensitive.You must use the complete name of the COM object. If you do not provide eValue, COMPROP( ) returns the value of cProperty.
cProperty
Specifies the name of the COM property to set. The following table lists possible values of cProperty.cProperty Description UTF8 Determines whether UNICODE strings returned from a COM object are converted to ANSI. Conversion is performed by default. PUTREF Determines if initial object assignment is PROPERTY_PUT (default) or PUTREF. eValue
Specifies a value representing behavior to apply to the cProperty. The following table lists values for eValue.eValue Description 0 Apply default behavior. 1 Apply nondefault behavior as described in the table for cProperty. For example, 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 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 PUTREF, and Visual FoxPro defaults to PROPERTY_PUT.
Return Values
COMPROP( ) returns the value of cProperty.
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 PUTREF rather than PROPERTY_PUT:
=COMPROP(oForm.OLECONTROL1, 'PUTREF',1)