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
 ImageEnFolderMView Drag and Drop
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

John

USA
94 Posts

Posted - Nov 19 2016 :  14:43:17  Show Profile  Reply
Hello

I use the existing drag and drop functionality of the ImageEnFolderMView components to drag and drop images from ImageEnFolderMView1 to ImageEnFoldeMView2. Of the existing 5 drag and drop procedures associated with this component, only OnDragOver has a Boolean Accept parameter. I allow/reject dropping an image on the second component with the following code.

procedure TformPresentations.ImageEnFolderMView2DragOver(Sender, Source: TObject; X, Y: Integer; State: TDragState; var Accept: Boolean);
var
  imgX, imgY: integer;
  tempInsertPoint: Integer;
begin
  if Source = ImageEnFolderMView1 then
    begin
      if wwDBComboBoxExistingLayouts.ItemIndex = -1 then
        begin
          Accept := True;
        end
      else
        begin
          Accept := False;
//          MessageDlg('New images can not be added to an existing presentation layout.',
//                     mtError, [mbOK], 0);
//          Abort
        end;
    end

  else

    begin
      if Source = ImageenFolderMView2 then
        begin
          Accept := true;
          tempInsertPoint := ImageEnFolderMView2.InsertingPoint(X, Y);
          imgX := ImageEnFolderMView2.ImageX[tempInsertPoint];
          imgY := ImageEnFolderMView2.ImageY[tempInsertPoint];
          ImageEnFolderMView2.Paint;
          with ImageEnFolderMView2.GetCanvas do
            begin
              Pen.Color := clRed;
              Pen.Style := psDot; // display a dotted line
              Pen.Width := 1;  // a dotted line only works if pen width is 1 otherwise it will be a solid line
              // draw the line vertically at the insert point
              MoveTo(imgX, imgY);
              LineTo(imgX, imgY + ImageEnFolderMView2.ThumbHeight - 10);
            end;
        end;
     end;
end;

Problem:
If I inform the user when an image is rejected by enabling the disabled MessageDlg, the message is repeated in infinitum irrespective of adding the Abort statement following the MessageDlg.

Suggestions??

John

xequte

38615 Posts

Posted - Nov 20 2016 :  04:07:00  Show Profile  Reply
Hi John

If you are using the built in Windows compatible drag/drop (TImageEnFolderMView.AutoDragFiles) then you need to use the OnDropFiles event to cancel the drop:

http://www.imageen.com/help/TImageEnFolderMView.OnDropFiles.html

Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page

John

USA
94 Posts

Posted - Nov 20 2016 :  23:51:51  Show Profile  Reply
Nigel

I have AutoDragFiles := [] and AutoDropFiles := []. Additionally, the OnDropFiles event does not fire. The two ImageEnFolderView components involved are both located on the same form.

I can successfully prevent moving a file from the source ImageEnFolderMView1 to the recipient ImageEnFolderMView2 via the event shown in the original post and below. The issue is that if I enable the remarked out MessageDlg in the code above, the messagedlg redisplays each time the OK button is depressed.

procedure TformPresentations.ImageEnFolderMView2DragOver(Sender, Source: TObject; X, Y: Integer; State: TDragState; var Accept: Boolean);
var
  imgX, imgY: integer;
  tempInsertPoint: Integer;
begin
  if Source = ImageEnFolderMView1 then
    begin
      if wwDBComboBoxExistingLayouts.ItemIndex = -1 then
        begin
          Accept := True;
        end
      else
        begin
          Accept := False;
//          MessageDlg('New images can not be added to an existing presentation layout.',
//                     mtError, [mbOK], 0);
        end;
    end
  else
     ......etc.



John
Go to Top of Page

xequte

38615 Posts

Posted - Nov 22 2016 :  03:51:24  Show Profile  Reply
Hi John

OK, you are just using standard DragDrop methods.

Why not just delay the call to MessageDlg, e.g. by posting a message to the form.

Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: