ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Drag&Drop From TImageEnMView

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

View 
UserName:
Password:
Format  Bold Italicized Underline  Align Left Centered Align Right  Horizontal Rule  Insert Hyperlink   Browse for an image to attach to your post Browse for a zip to attach to your post Insert Code  Insert Quote Insert List
   
Message 

 

Emoji
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Black Eye [B)]
Frown [:(] Shocked [:0] Angry [:(!] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
w2m Posted - Sep 11 2014 : 17:35:58
I can drag and drop an image from explorer to TImageEnView with no problem, but I can not find any demos that show how to drag and drop a selected image from TImageEnMView in one application to another application with a TImageEnView.

Can anyone help with a little code or a demo?

Bill Miller
Adirondack Software & Graphics
Email: w2m@hughes.net
EBook: http://www.imageen.com/ebook/
Custom Commercial ImageEn Development
4   L A T E S T    R E P L I E S    (Newest First)
graph_man Posted - Oct 10 2018 : 15:21:33
Bill, thank you for your example.
Is there ability to drag-and-drop several pages from ImageEnMView (program1) to ImageEnMView (program2)?
xequte Posted - Sep 13 2014 : 16:22:16
Hi Bill

Sorry, I misread your original post. I thought you mean dragging of files, rather than the image content. Nice work.




Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
w2m Posted - Sep 12 2014 : 14:03:20
It turns out that this is a bit more complicated then a simple ImageEn demo and requires the use of other third-party components to facilitate the drag and drop. Anders Melander developed a good freeware Drag & Drop Component Suite, (http://melander.dk/delphi/dragdrop/) but he stopped updating it in 2010 so it will not compile with the XE versions of Delphi. So I obtained a copy of the Raize Drop Master 2 components (http://www.raize.com/DevTools/DropMaster/Default.asp).

I then built two applications:
A Target Destination Application that accepts drops from a Target Source Application.

The Target Destination Application contains a TDMGraphicTarget component and a TImageEnView component. The TDMGraphicTarget.AcceptorControl is set to ImageEnView1. Then the following code is added to the DMGraphicTarget1Drop event:
procedure TForm1.DMGraphicTarget1Drop(Sender: TObject; Acceptor: TWinControl;
  ThePicture: TPicture; X, Y: Integer);
var
  iString: string;
begin
  if Assigned(ThePicture) then
  begin
    { Assign ThePicture.bitmap to TImageEnView. }
    ImageEnView1.Bitmap.Assign(ThePicture.Bitmap);
    { Optionally stretch depending on checkbox state }
     if CheckBox1.Checked then
       ImageEnView1.Fit
     else
       ImageEnView1.Zoom := 100;
    { Show in the label what kind of object got dropped }
    case (Sender as TDMGraphicTarget).DroppedGraphicFormat of
      dgfBitmap: iString := 'Bitmap';
      dgfMetafile: iString := 'Metafile';
    else
      iString := '???'; { Should never happen! }
    end;
    Label1.caption := 'Dropped a '+ iString;
  end;
end;

The Target Source Application contains a TDMGraphicSource and a TImageEnView component. Then in the TImageEnOnbMouseDown event add the following code:
procedure TForm1.ImageEnMView1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
var
  iBitmap: TBitmap;
begin
  { Detect a drag with any button }
  if DragDetectEx(ImageEnMView1.Handle, POINT(X,Y), Button) then
  begin
    { Tell the graphic source which button we got}
    DMGraphicSource1.MouseButton := Button;
    { Make a temporary bitmap }
    iBitmap := TBitmap.Create;
    try
      { Assign the ImageEnMView1.Bitmap to the temporary bitmap }
      iBitmap.Assign(ImageEnMView1.Bitmap);
      { Now, we have a bitmap, so assign it to the graphic source's picture }
      DMGraphicSource1.Picture.Graphic := iBitmap;
      { Now do the drag! }
      DMGraphicSource1.Execute;
      { In case we made a big bitmap, let it go.  Otherwise, it will live on unnecessarily in the Picture property of the TDMGraphicSource. }
      DMGraphicSource1.Picture := nil;
    finally
      { Clean up. }
      iBitmap.Free;
    end;
  end;
end;


The Target Source Application can also drag images to other applications like Microsoft Word. Phew... it works nicely...

Bill Miller
Adirondack Software & Graphics
Email: w2m@hughes.net
EBook: http://www.imageen.com/ebook/
Custom Commercial ImageEn Development
xequte Posted - Sep 12 2014 : 13:53:33
Hi Bill

TImageEnFolderMView supports dragging of images to explorer and other applications, so you might want to use that, or just use the code if you want to stay with TImageEnMView.



Nigel
Xequte Software
www.xequte.com
nigel@xequte.com