// Allow images from a TImageEnMView to be dropped onto a TImageEnView as layers
procedure TMainForm.ImageEnMView1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
begin
if ssLeft in Shift then
begin
(Sender as TImageEnMView).MouseInteract := [];
(Sender as TImageEnMView).IEBeginDrag(False, -1);
end;
end;
procedure TMainForm.ImageEnMView1EndDrag(Sender, Target: TObject; X, Y: Integer);
begin
(Sender as TImageEnMView).IEEndDrag();
(Sender as TImageEnMView).MouseInteract := [mmiSelect];
end;
procedure TMainForm.ImageEnView1DragOver(Sender, Source: TObject; X, Y: Integer; State: TDragState; var Accept: Boolean);
begin
if (Source is TImageEnMView) then
Accept := True;
end;
procedure TMainForm.ImageEnView1DragDrop(Sender, Source: TObject; X, Y: Integer);
var
bmp: TIEBitmap;
idx: Integer;
begin
idx := TImageEnMView(Source).SelectedImage;
if idx >= 0 then
begin
bmp := ImageEnMView1.GetTIEBitmap( idx );
ImageEnView1.LayersAdd( bmp );
ImageEnView1.CurrentLayer.PosX := ImageEnView1.XScr2Bmp( X );
ImageEnView1.CurrentLayer.PosY := ImageEnView1.YScr2Bmp( Y );
TImageEnMView(Source).ReleaseBitmap(idx, False);
ImageEnView1.Update();
end;
end;