示例#1
0
void mtlrchApp::EvDropFiles (TDropInfo drop)
{
    // Number of files dropped.
    int totalNumberOfFiles = drop.DragQueryFileCount();

    TFileList* files = new TFileList;

    for (int i = 0; i < totalNumberOfFiles; i++) {
        // Tell DragQueryFile the file interested in (i) and the length of your buffer.
        int     fileLength = drop.DragQueryFileNameLen(i) + 1;
        char    *fileName = new char[fileLength];

        drop.DragQueryFile(i, fileName, fileLength);

        // Getting the file dropped. The location is relative to your client coordinates,
        // and will have negative values if dropped in the non client parts of the window.
        //
        // DragQueryPoint copies that point where the file was dropped and returns whether
        // or not the point is in the client area.  Regardless of whether or not the file
        // is dropped in the client or non-client area of the window, you will still receive
        // the file name.
        TPoint  point;
        BOOL    inClientArea = drop.DragQueryPoint(point);
        files->Add(new TFileDrop(fileName, point, inClientArea, this));
    }

    // Open the files that were dropped.
    AddFiles(files);

    // Release the memory allocated for this handle with DragFinish.
    drop.DragFinish();
}
示例#2
0
//
/// Constructs a TFileDroplet given a DropInfo and a file index.
///
/// The location is relative to the client coordinates, and will have negative
/// values if dropped in the non-client parts of the window.
///
/// DragQueryPoint copies that point where the file was dropped and returns whether
/// or not the point is in the client area.  Regardless of whether or not the file
/// is dropped in the client or non-client area of the window, you will still
/// receive the file name.
//
TFileDroplet::TFileDroplet(TDropInfo& drop, int i)
{
  // Tell DragQueryFile the file wanted (i) and the length of the buffer.
  //
  int  namelen = drop.DragQueryFileNameLen(i) + 1;
  FileName = new tchar[namelen];

  drop.DragQueryFile(i, FileName, namelen);

  InClientArea = drop.DragQueryPoint(Point);
}