TNGFileDescriptorFormat

<< Click to Display Table of Contents >>

Navigation:  Data Formats >

TNGFileDescriptorFormat

Previous pageReturn to chapter overviewNext page

TNGFileDescriptorFormat class implements common FILEDESCRIPTOR data format and allows to drag/receive virtual files created on-the-fly from any data stream. NG Drag&Drop use special TNGFileArray type, which is a dynamic array of special TNGFileDescriptor records, for working with FILEDESCRIPTOR data. Please note that this format is specially designed to be used together with TNGFileContentsFormat format. While this format provide descriptions (like names, sizes, file dates and attributes) of dragging virtual files, TNGFileContentsFormat provides data streams for dragging virtual files.

 

TNGFileDescriptor record allows to specify the following file properties:

 

Name - the name of file, like 'MyText.txt'

Clsid - is the special GUID like identifier for special file system objects, like "Recycle Bin". Please read MSDN documentation.

Attributes - file attributes, like for any other file.

CreationTime, LastAccessTime, LastWriteTime - file times.

Size - the size of corresponding data stream, in bytes.

Flags - this property indicates, which other properties has been specified. A flag is set up automatically, when the corresponding property value is assigned. Actually, only Name property is required to be specified, all other properties are optional.

 

The class declares two methods: Data and Ref. Data method can be used to drag virtual files at the source side, while Ref method can be used to receive files data data at the target side. NG Drag&Drop declares special type alias CF.FILEDESCRIPTOR to make user's code more readable:

 

SetLegnth(d, 1);
d[0].Name := 'c:\MyText1.txt';
d[0].Size := 10;
 
NGDropSource.Add(CF.FILEDESCRIPTOR.Data(d))

            .Add(CF.FILECONTENTS.Data(...)) 
            .Execute;

 
NGDropTarget.Register(MyTargetPanel, procedure(C: TNGTargetContext)
var
  d:   TNGFileArray;

  cnt: TNGFileContents;
begin
  if C.Accept(CF.FILEDESCRIPTOR.Ref(@d)) and 

     C.Accept(CF.FILECONTENTS.Ref(@cnt)) then
    ShowFiles(d);
end);