GetFormat, SetFormat
These are methods of the data object that contains data being dragged with OLE drag and drop. GetFormat tells you what kinds of data are available. SetFormat lets you expand that list.
Usage |
lIsItThere = oDataObject.GetFormat( nFormat | cFormat ) oDataObject.SetFormat( nFormat | cFormat ) |
Parameter |
Value |
Meaning |
lIsItThere |
.T. |
The data object contains data in the specified format. |
.F. |
The data object doesn't contain any data in the specified format. |
|
nFormat |
1, 7 or 13 |
The data object contains textual data in ASCII, OEM or Unicode format, respectively. As far as we can tell, no VFP controls automatically supply either OEM or Unicode format data (using the American English version of VFP and Windows), though other applications may and you can provide data in one of those formats. |
15 |
The data object contains a list of files. |
|
Any other number |
The data object contains data in a custom format. |
|
cFormat |
"OLE Variant Array" |
The data object contains multiple data items, in their original format. We haven't been able to find any drag source that automatically provides data in this format, but it can be used to drag the contents of an array without converting all the data into character. |
"OLE Variant" |
The data object contains data in its original type. For example, data from a spinner is returned as numeric, using this format, while it's character with format 1. |
|
"VFP Source Object" |
The data object contains a reference to the data source for this drag. This is always true when dragging from VFP objects. |
|
Any other string |
The data object contains data in a custom format. |
You don't actually have to explicitly create new formats with SetFormat. You can just call SetData, passing both the data and the format. |
Example |
* This code could go in an edit box's OLEDragDrop method. * If the data dropped comes from a listbox, it creates a * comma-delimited string of the selected items and assigns * that string to the edit box. LPARAMETERS oDataObject, nEffect, nButton, nShift, ; nXCoord, nYCoord LOCAL oSource, cResult, nCount IF oDataObject.GetFormat("VFP Source Object") * We have a VFP data source, so get a reference oSource = oDataObject.GetData("VFP Source Object") * Is it a list? If so, loop through IF UPPER(oSource.BaseClass) = "LISTBOX" cResult = "" FOR nCount = 1 TO oSource.ListCount IF oSource.Selected[ nCount ] cResult = cResult + oSource.List[ nCount ] + "," ENDIF ENDFOR * Strip trailing comma cResult = SUBSTR(cResult, 1, LEN(cResult)-1) This.Value = cResult * Prevent normal dragdrop behavior NODEFAULT ENDIF ENDIF * See OLEDrag for an example of creating a custom format. |
See Also |
DataObject, GetData, OLE drag and drop, OLEDragDrop, OLESetData, OLEStartDrag, SetData |