Adds a supported format and possibly its data to a DataObject object.
| VB | object.SetData([ ByVal Data As Variant ] , [ ByVal Format As Variant ] ) |
object
Data
The data to be passed to the DataObject object. The Data argument is optional.
Format
The data format. The Format argument is optional.
| Format | Value | Description |
|---|---|---|
| sftCFText | 1 | Text (as a String value) |
| sftCFBitmap | 2 | Bitmap (as Picture object) |
| sftCFMetafile | 3 | Metafile (as Picture object) |
| sftCFDIB | 8 | Device independent bitmap (as Picture object) |
| sftCFFiles | 15 | List of files. SetData cannot be used to supply data for this format. Use the Files collection instead. |
| sftCFRTF | -16639 | Rich text format (as String value) |
The SetData method adds a supported format and possibly its data to a DataObject object.
The Data argument is optional. This allows you to set several different formats that the source component can support without having to load the data separately for each format. Multiple formats are set by calling SetData several times, each time using a different format. If you wish to start fresh, use the Clear method to clear all data and format information from the DataObject.
The Format argument is also optional, but either the Data or Format argument must be specified. If Data is specified, but not Format, the format of the data is determined automatically. If this is unsuccessful, then an error is generated. When the target requests the data and a format was specified, but no data was provided, the source's OLESetData event occurs, and the source can then provide the requested data type.
It is possible for the GetData and SetData methods to use data formats other than those listed as valid Format argument, including user-defined formats registered with Windows via the RegisterClipboardFormat() API function. The SetData method requires the data to be in the form of a byte array when it does not recognize the data format specified. The GetData method always returns data in a byte array when it is in a format that it doesn't recognize, although this may be transparently converted into other data types, such as strings. The byte array returned by GetData will be larger than the actual data when running on some operating systems, with arbitrary bytes at the end of the array. This allocation of memory is often larger than is actually required for the data. Therefore, there may be extraneous bytes near the end of the allocated memory segment.
See Reorder Sample
' drag & drop has ended, clean up
ClearImage
StartTabIndex = -1
End Sub
Private Sub SftTabs1_OLEStartDrag(Data As SftTabsLib70.DataObject, AllowedEffects As Long)
' We just started to drag (using OLEDrag)
' Add some text to the Data object
Data.SetData "Can't drag tabs outside the tab control" ' any data will do to get things going
AllowedEffects = vbDropEffectMove ' we're moving tabs
End Sub
Private Sub SftTabs1_OLEDragOver(Data As SftTabsLib70.DataObject, TargetTab As Integer, Effect As Long, Button As Integer, Shift As Integer, x As Single, y As Single, State As SftTabsLib70.SftTabsOLEDragOverConstants)
Dim Left As Single, Top As Single, Width As Single, Height As Single
' we are over the tab control
If State = overSftTabs ThenSee Also DataObject Object | Object Hierarchy