Lazarus

Programming => Widgetset => Win32/64 => Topic started by: Mike.Cornflake on October 19, 2018, 07:44:01 am

Title: Initiating Drag/Drop files from Lazarus Application
Post by: Mike.Cornflake on October 19, 2018, 07:44:01 am
I am displaying a list of files in a TDBGrid.  I want to be able to drag a list of selected records from my grid and drop them onto a program which accepts WM_DROPFILES.

My environment is Windows (Windows 7 64bit).

It's been far too long since I did any drag/drop, I've never done it inter-application (certainly OnEndDrag doesn't seem useful) and I've never done it with WM_DROPFILES.  Does anyone have any pointers? 

Ta

PS I'm currently ploughing through MS docs like https://docs.microsoft.com/en-us/windows/desktop/shell/dragdrop... Hoping not to have to implement from scratch...
Title: Re: Initiating Drag/Drop files from Lazarus Application
Post by: ASerge on October 20, 2018, 03:53:46 pm
I want to be able to drag a list of selected records from my grid and drop them onto a program which accepts WM_DROPFILES.
My environment is Windows (Windows 7 64bit).
An example of using attachment:
In the new project add the TMemo component to the form, fill in its lines with the full file names and add the code with the event:
Code: Pascal  [Select][+][-]
  1. procedure TForm1.Memo1MouseDown(Sender: TObject; Button: TMouseButton;
  2.   Shift: TShiftState; X, Y: Integer);
  3. begin
  4.   if DragDropCopyComplete(Memo1.Lines) then
  5.     Caption := 'Dropped';
  6. end;
Then, at run time, drag Memo to some directory in Windows Explorer.
Title: Re: Initiating Drag/Drop files from Lazarus Application
Post by: Mike.Cornflake on October 22, 2018, 08:07:17 am
Many thanks @ASerge.  I've downloaded your code, and it appears to be spot on.  It'll be a few days before I get a chance to investigate, but I'm confident.  Much appreciated.
Title: Re: Initiating Drag/Drop files from Lazarus Application
Post by: Mike.Cornflake on October 24, 2018, 08:38:56 am
Worked flawlessly, many thanks.

I've added the following acknowledgement to the top of the supplied unit

Code: Pascal  [Select][+][-]
  1. (* Source: http://forum.lazarus.freepascal.org/index.php/topic,42920.msg299974.html
  2.    Contributed by forum user @ASerge
  3. *)      
Title: Re: Initiating Drag/Drop files from Lazarus Application
Post by: mgc on December 30, 2020, 11:42:51 pm
I want to be able to drag a list of selected records from my grid and drop them onto a program which accepts WM_DROPFILES.
My environment is Windows (Windows 7 64bit).
An example of using attachment:
In the new project add the TMemo component to the form, fill in its lines with the full file names and add the code with the event:
Code: Pascal  [Select][+][-]
  1. procedure TForm1.Memo1MouseDown(Sender: TObject; Button: TMouseButton;
  2.   Shift: TShiftState; X, Y: Integer);
  3. begin
  4.   if DragDropCopyComplete(Memo1.Lines) then
  5.     Caption := 'Dropped';
  6. end;
Then, at run time, drag Memo to some directory in Windows Explorer.

I cannot compile the unit uShellDragDrop.pp in Lazarus 2.0.10 and FPC 3.2.0
The error message is "No matching implementation for interface method".
Any idea what is happening?
Thanks.
TinyPortal © 2005-2018