On the last meters when porting my Delphi 7 app to Lazarus 2.0.12 (Windows x64 only) i got a crash at Drop and don't know if i did something did illegitimate.
What did i try?
I've an already established DragDrop functionality established with pre-Lazarus (Delphi7) means and noticed some drag animation effects were missing. I got aware that Lazarus will work differently...
After studying some threads in the forum i tried to use the example “dragimagelist” for my use cae.
This is a custom treeview where i have copies from system icons stored in an ImageList. Planning to use those icons as ghost images (node icons as ghost image).
Is there something illegitimate so far? I'm needing the DragObject for the ghost images only.
That what i did:
constructor TMyDragObject.CreateWith(AControl: TControl; il: TImageList; imgidx: Integer);
var Bitmap: TBitmap;
begin
inherited Create(AControl);
FDragImages := TDragImageList.Create(AControl);
AlwaysShowDragImages := True;
Bitmap := TBitmap.Create;
Bitmap.Width := 16;
Bitmap.Height := 16;
Bitmap.Canvas.Changed;
FDragImages.Width := Bitmap.Width;
FDragImages.Height := Bitmap.Height;
ImageList_Draw(il.ResolutionByIndex[0].Reference.Handle, imgidx, Bitmap.Canvas.Handle, 0, 0, ILD_TRANSPARENT);
FDragImages.Add(Bitmap, nil);
Bitmap.Free;
end;
At OnStartDrag i do:
procedure TMyCustomTreeview.DirTreeDoOnStartDrag(Sender: TObject; var DragObject: TDragObject);
var imgidx : Integer;
begin
imgidx := 15; // hard-coded temporarely simply for testing
FDragObject := TMyDragObject.CreateWith(Sender as TControl, FTvImageList, imgidx);
DragObject := FDragObject;
end;
Works quite fine so far (although the image is not quite transparent yet, well anyhow), but it crashes when entering the OnDragDrop event.
At
OnDragOver i did nothing special. It's simply decided where to Accept Drag and where not.
At
OnDragDrop i try at first to HideDragImage and Free it (it is stored in FDragObject)
But before that it directly crashes (SIGSEV) when hen having entered the procedure.
It crashes here: in dragimagelist.inc (it halts in first line):
procedure TDragImageListResolution.HideDragImage;
begin
if Dragging then
TWSDragImageListResolutionClass(WidgetSetClass).HideDragImage(Self, 0, False);
end;
If i directly look onto the WM_RBUTTONUP message: that will be entered, but crashes here immediately.
Does anybody having done such similar has an idea where the flaw might be located?