Hide

SftTabs/OCX 6.5 - Tab Control for VB6

Display
Print

DataObject.GetData Method

Retrieves data of a specified format from a DataObject object.

Syntax

VBData = object.GetData([ ByVal Format As Variant ] ) As Variant

object

A DataObject object.

Format

The data format requested. The Format argument is optional. If Format is not specified, GetData returns data in a suitable format.

FormatValueDescription
sftCFText1Text (as a String value)
sftCFBitmap2Bitmap (as Picture object)
sftCFMetafile3Metafile (as Picture object)
sftCFDIB8Device independent bitmap (as Picture object)
sftCFFiles15List of files. GetData cannot be used to retrieve this format. Use the Files collection instead.
sftCFRTF-16639Rich text format (as String value)

Data

Returns the data in the requested Format as a Variant.

Comments

The GetData method retrieves data of a specified format from a DataObject object.

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.

Example

This example uses a picture box (Picture1) which is placed on the same form as the tab control (SftTabs1). A valid bitmap or icon has to be loaded into the picture box (Picture property). By dragging the image from the picture box to a tab of the tab control, the image is added to the tab as tab graphic.

Private Sub Form_Load()
     Picture1.OLEDragMode = OLEDragSftControlManual
     SftTabs1.OLEDropMode = OLEDropSftControlManual
End Sub

Private Sub SftTabs1_OLEDragDrop(Data As SftTabsLib.DataObject, TargetTab As Integer, _
     Effect As Long, Button As Integer, Shift As Integer, x As Single, y As Single)
     With SftTabs1.Direct
         If Data.GetFormat(sftCFDIB) Then
             ' Bitmap
             If TargetTab >= 0 Then
                 Set .Tab(TargetTab).Image.Picture = Data.GetData(sftCFDIB)
             End If
         End If
     End With
End Sub

Private Sub SftTabs1_OLEDragOver(Data As SftTabsLib.DataObject, TargetTab As Integer, _
     Effect As Long, Button As Integer, Shift As Integer, x As Single, y As Single, _
     State As SftTabsLib.SftControlOLEDragOverConstants)
     If TargetTab >= 0 Then
         Effect = vbDropEffectCopy
     Else
         Effect = vbDropEffectNone
     End If
End Sub

See Also DataObject Object | Object Hierarchy


Last Updated 08/13/2020 - (email)
© 2024 Softel vdm, Inc.