ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder
ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 File DragDrop from Explorer to IEM not working
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

yogiyang

India
619 Posts

Posted - Jan 02 2020 :  01:30:41  Show Profile  Reply
Hello,

When I was using IE 8.6.0 the following code was working fine:
procedure TfrmMain.DropFiles(Sender: TObject; ssFiles: TStrings;
  dwEffect: Integer);
{ Add the dropped image files to ImageEnMView }
var
  i: Integer;
  iFileCount: Integer;
  iDroppedFileName: string;
  iDroppedFilePath: string;
  iFileName: string;
  iFrameCount: Integer;
  iIndex: Integer;
begin
  iFileCount := ssFiles.Count;
  if iFileCount = 1 then
  begin { Single file dropped }
    iDroppedFileName := Trim(ssFiles.GetText);
    iDroppedFilePath := ExtractFileDir(iDroppedFileName);
    if FileExists(iDroppedFileName) then
    begin
      iFrameCount := IEGetFileFramesCount(iDroppedFileName);
      if iFrameCount = 0 then
      begin
        MessageBox(0,
          'The dropped file does not contain a supported image type.',
          'No Supported Image Types', MB_ICONWARNING or MB_OK);
        exit;
      end
      else if iFrameCount = 1 then
      begin
        { Single frame file }
        iFileName := ExtractFileName(iDroppedFileName);
        iIndex := iemPhotos.AppendImage(iDroppedFileName);
        if iemPhotos.MIO.Aborting then
        begin
          MessageBox(0,
            'There was an error opening the dropped image.  ImageEn can not open the image.',
            'Error Opening Image', MB_ICONWARNING or MB_OK);
          exit;
        end
        else
        begin
          iemPhotos.ImageBottomText[iIndex] := iFileName;
          iemPhotos.ImageInfoText[iIndex] :=
            IntToStr(iemPhotos.MIO.Params[iIndex].Width) + ' x ' +
            IntToStr(iemPhotos.MIO.Params[iIndex].Height);
          iemPhotos.SelectedImage := iemPhotos.ImageCount - 1; // iIndex;
        end;
      end;
    end;
  end
  else { Multiple files dropped }
  begin
    try
      Screen.Cursor := crHourGlass;
      for i := 0 to iFileCount - 1 do
      begin
        { Get filenames dropped }
        iDroppedFileName := Trim(ssFiles[i]);
        iDroppedFilePath := ExtractFileDir(iDroppedFileName);
        iemPhotos.InsertImage(i, iDroppedFileName);
        if iemPhotos.MIO.Aborting then
        begin
          MessageBox(0,
            'There was an error opening the dropped image.  ImageEn can not open the image.',
            'Error Opening Image', MB_ICONWARNING or MB_OK);
          exit;
        end
        else
        begin
          iemPhotos.ImageBottomText[i] := ExtractFileName(iDroppedFileName);
          iemPhotos.ImageInfoText[i] := IntToStr(iemPhotos.MIO.Params[i].Width)
            + ' x ' + IntToStr(iemPhotos.MIO.Params[i].Height);
        end;
      end;
      iemPhotos.SelectedImage := 0;
    finally
      Screen.Cursor := crDefault;
    end;
  end;
end;

procedure TfrmMain.FormCreate(Sender: TObject);
begin
iemPhotos.LookAhead := 500;
  iemPhotos.MaintainInvisibleImages := -1;
  iemPhotos.ShowText := True;
  iemPhotos.EnableAdjustOrientation := True;

{ Create a TIEFileDragDrop class }
  AFileDrop := TIEFileDragDrop.Create(iemPhotos, DropFiles);
  { Do not explicity free the FileDrop object }
  RegisterExpectedMemoryLeak(AFileDrop);
  { Activate dropping }
  AFileDrop.ActivateDropping := True;
end;



But in newer version this code is not working.

I also tried to use the component - TIEFileDragDrop but and still not able to receive any dropped files.

What to do?

TIA


Yogi Yang

xequte

5390 Posts

Posted - Jan 05 2020 :  22:10:53  Show Profile  Reply
Hi Yogi

What version are you using?

This works fine in in v8.7.6:

procedure TForm1.DropFiles(Sender: TObject; ssFiles: TStrings; dwEffect: Integer);
var
  i: Integer;
  aFileName: string;
begin
  // Add the dropped image files to ImageEnMView
  for i := 0 to ssFiles.Count - 1 do
  begin
    aFileName := Trim(ssFiles[i]);
    iemPhotos.InsertImage(i, aFileName);
    iemPhotos.ImageBottomText[i] := ExtractFileName(aFileName);
  end;
  iemPhotos.SelectedImage := 0;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  AFileDrop := TIEFileDragDrop.Create(Self);
  AFileDrop.DropControl := iemPhotos;
  AFileDrop.OnFileDrop  := DropFiles;

  // Because we do not explicity free the FileDrop object
  RegisterExpectedMemoryLeak(AFileDrop);

  // Activate dropping
  AFileDrop.EnableDropping := True;
end;


Nigel
Xequte Software
www.imageen.com
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To: