Hide

SftBox/OCX 5.0 - Combo Box Control

Display
Print

DataObject.GetData Method

Retrieves data of a specified format from a DataObject object.

Syntax

VB.NETData = object.GetData([ ByVal Format As Object ] ) As Object
VBData = object.GetData([ ByVal Format As Variant ] ) As Variant
C#.NETobject Data = object.GetData(object Format);
VC++_variant_t Data = object->GetData(const _variant_t& Format = vtMissing);
CHRESULT object->raw_GetData(VARIANT Format, VARIANT* Data);

object

A DataObject object.

Format

The data format requested (see SftOLEClipboardConstants). 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. The GetData method cannot be used to retrieve this format. Use the DataObject.Files collection instead.
sftCFRTF-16639Rich text format (as String value)

Data

Returns data of a specified format from a DataObject object.

Comments

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

It is possible for the GetData method and DataObject.SetData method 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 DataObject.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.

Examples

VB.NET

        ' user is moving from/to the static or drop down portion
        comboTarget.DropDown.RollUp(500)  ' 1/2 second
    End If
End Sub

Private Sub comboTarget_OLEDragDrop(ByVal sender As Object, ByVal e As AxSftBoxLib50._ISftBoxEvents_OLEDragDropEvent) Handles comboTarget.OLEDragDrop
    If e.data.GetFormat(SftOLEClipboardConstants.sftCFText) Then
        Dim itemIndex As Integer
        itemIndex = comboTarget.Items.Insert(e.data.GetData(SftOLEClipboardConstants.sftCFText), comboTarget.Items.DropIndex)
        comboTarget.Items.Selection = itemIndex
    End If
    If e.data.GetFormat(SftOLEClipboardConstants.sftCFBitmap) Then
        Dim itemIndex As Integer
        itemIndex = comboTarget.Items.Insert("A Bitmap", comboTarget.Items.DropIndex)
        Dim o As Object = e.data.GetData(SftOLEClipboardConstants.sftCFBitmap)
        comboTarget.get_Item(itemIndex).Image.Picture = o 'as stdole.IPictureDisp

VB6

Private Sub ComboTarget_OLEDragDrop(Data As SftBoxLib50.DataObject, Effect As Long, Button As Integer, Shift As Integer, x As Single, y As Single)
    Dim ItemIndex As Long
    If Data.GetFormat(sftCFText) Then
        ItemIndex = ComboTarget.Items.Insert(Data.GetData(sftCFText), ComboTarget.Items.DropIndex)
        ComboTarget.Items.Selection = ItemIndex
    End If
    If Data.GetFormat(sftCFDIB) Then
        ItemIndex = ComboTarget.Items.Insert("A Bitmap", ComboTarget.Items.DropIndex)
        Set ComboTarget.Item(ItemIndex).Image.Picture = Data.GetData(sftCFDIB)
        ComboTarget.Items.Selection = ItemIndex
    End If
    If Data.GetFormat(sftCFFiles) Then
        Dim vData As Variant, ToIndex As Long
        ToIndex = ComboTarget.Items.DropIndex
        For Each vData In Data.Files
            ItemIndex = ComboTarget.Items.Insert(vData, ToIndex)

C#

        // user is moving from/to the static or drop down portion
        comboTarget.DropDown.RollUp(500);  // 1/2 second
    }
}

private void comboTarget_OLEDragDrop(object sender, AxSftBoxLib50._ISftBoxEvents_OLEDragDropEvent e)
{
    if (e.data.GetFormat((short) SftOLEClipboardConstants.sftCFText)) {
        int itemIndex = comboTarget.Items.Insert(e.data.GetData(SftOLEClipboardConstants.sftCFText) as string, comboTarget.Items.DropIndex);
        comboTarget.Items.Selection = itemIndex;
    }
    if (e.data.GetFormat((short) SftOLEClipboardConstants.sftCFBitmap)) {
        int itemIndex = comboTarget.Items.Insert("A Bitmap", comboTarget.Items.DropIndex);
        object o = e.data.GetData(SftOLEClipboardConstants.sftCFBitmap);
        comboTarget.get_Item(itemIndex).Image.Picture = o as stdole.IPictureDisp;
        comboTarget.Items.Selection = itemIndex;

See Also DataObject Object | Object Hierarchy


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