method ExDataObject.GetData (Format as Integer)

Returns data from a ExDataObject object in the form of a variant.

TypeDescription
Format as Integer An exClipboardFormatEnum expression that defines the data's format.
ReturnDescription
VariantA Variant value that contains the ExDataObject's data in the given format.

Use GetData property to retrieve the clipboard's data that has been dragged to the ExFileView control. It's possible for the GetData and SetData methods to use data formats other than exClipboardFormatEnum , including user-defined formats registered with Windows via the RegisterClipboardFormat() API function. The GetData method always returns data in a byte array when it is in a format that it is not recognized. Use the Files property to retrieve the filenames if the format of data is exCFiles. The OLEDragDrop event notifies your application that the user drags some data on the control. The control fires the OLEStartDrag event to notify your application that the user stars dragging files. The GetFormat property returns a value indicating whether the ExDataObject's data is of specified format

The following VB sample retrieves the text being dragged to the control:

Private Sub ExFileView1_OLEDragDrop(ByVal Data As EXFILEVIEWLibCtl.IExDataObject, Effect As Long, ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
    With Data
        If .GetFormat(EXFILEVIEWLibCtl.exClipboardFormatEnum.exCFText) Then
            MsgBox .GetData(EXFILEVIEWLibCtl.exClipboardFormatEnum.exCFText)
        End If
    End With
End Sub

The following C++ sample retrieves the text being dragged to the control:

#import <exfilevw.dll>
void OnOLEDragDropExfileview1(LPDISPATCH Data, long FAR* Effect, short Button, short Shift, long X, long Y) 
{
	EXFILEVIEWLib::IExDataObjectPtr spData( Data );
	if ( spData )
		if ( spData->GetFormat( 1 /*exCFText*/ ) )
		{
			CString strText = V2S( &spData->GetData( 1 /*exCFText*/ ) );
			MessageBox( strText );
		}
}

The C++ requires #import <exfilevw.dll> to import definitions for ExDataObject and ExDataObjectFiles objects. The #import <exfilevw.dll> generates the EXFILEVIEWLib namespace. If the exfilevw.dll file is located in other directory than system folder, the correct path should be provided, else a compiler error occurs.

The V2S function converts a VARIANT expression to a string, and may look like follows:

static CString V2S( VARIANT* pv, LPCTSTR szDefault = _T("") )
{
	if ( pv )
	{
		if ( pv->vt == VT_ERROR )
			return szDefault;

		COleVariant vt;
		vt.ChangeType( VT_BSTR, pv );
		return V_BSTR( &vt );
	}
	return szDefault;
}

The following VB.NET sample retrieves the text being dragged to the control:

Private Sub AxExFileView1_OLEDragDrop(ByVal sender As Object, ByVal e As AxEXFILEVIEWLib._IExFileViewEvents_OLEDragDropEvent) Handles AxExFileView1.OLEDragDrop
    With e.data
        If .GetFormat(EXFILEVIEWLib.exClipboardFormatEnum.exCFText) Then
            MessageBox.Show(.GetData(EXFILEVIEWLib.exClipboardFormatEnum.exCFText))
        End If
    End With
End Sub

The following C# sample retrieves the text being dragged to the control:

private void axExFileView1_OLEDragDrop(object sender, AxEXFILEVIEWLib._IExFileViewEvents_OLEDragDropEvent e)
{
	if (e.data.GetFormat(Convert.ToInt16(EXFILEVIEWLib.exClipboardFormatEnum.exCFText)))
		MessageBox.Show(e.data.GetData(Convert.ToInt16(EXFILEVIEWLib.exClipboardFormatEnum.exCFText)).ToString());
}

The following VFP sample retrieves the text being dragged to the control:

*** ActiveX Control Event ***
LPARAMETERS data, effect, button, shift, x, y

With data
	If .GetFormat( 1 ) Then && exCFText
		wait window nowait .GetData( 1 ) && exCFText
	EndIf
EndWith