Software Developer's Kit - ChemDraw

Send comments on this topic
SetData Method
See Also 
Value
The binary value of the data in the clipboard.
Format
The format argument is a number returned from a call to RegisterClipboardFormat().

Description

Member of ChemDraw Control.DataObject.

Adds a supported format and possibly its data to a DataObject object.

Syntax

Visual Basic
Public Sub SetData( _
   Optional ByVal Value As Variant, _
   Optional ByVal Format As Variant _
) 

Parameters

Value
The binary value of the data in the clipboard.
Format
The format argument is a number returned from a call to RegisterClipboardFormat().

Remarks

Sets data of a specified format to a DataObject object. The format argument is a number returned from a call to RegisterClipboardFormat(). The string used is one of the clipboard formats.

Example

'this reads from clipboard into a ChemDraw control
 Private Declare Function RegisterClipboardFormat Lib "user32" _
         Alias "RegisterClipboardFormatA" (ByVal lpString As String) As Long

 Private sub command_click()
     If  newDataType <> 0 Then
         Dim numBytes, i As Long
         Dim fileNum As Integer
         Dim newData() As Byte
         'reads the data in from the clipboard
         fileNum = FreeFile
         Open "CDXfile.cdx" For Binary As fileNum
         numBytes = LOF(fileNum)
         ReDim newData(numBytes)
         For i = 0 To numBytes - 1
             Get #FileNum, , newData(i)
         Next i
         Close fileNum
         'Sets the data type with which it will be created
         ChemDrawCtl.DataObject.SetData newData, newDataType
     End If
 End Sub

See Also