Forum > Win32/64

Initiating Drag/Drop files from Lazarus Application

(1/1)

Mike.Cornflake:
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...

ASerge:

--- Quote from: Mike.Cornflake on October 19, 2018, 07:44:01 am ---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).

--- End quote ---
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  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TForm1.Memo1MouseDown(Sender: TObject; Button: TMouseButton;  Shift: TShiftState; X, Y: Integer);begin  if DragDropCopyComplete(Memo1.Lines) then    Caption := 'Dropped';end;Then, at run time, drag Memo to some directory in Windows Explorer.

Mike.Cornflake:
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.

Mike.Cornflake:
Worked flawlessly, many thanks.

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


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---(* Source: http://forum.lazarus.freepascal.org/index.php/topic,42920.msg299974.html   Contributed by forum user @ASerge*)      

mgc:

--- Quote from: ASerge on October 20, 2018, 03:53:46 pm ---
--- Quote from: Mike.Cornflake on October 19, 2018, 07:44:01 am ---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).

--- End quote ---
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  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TForm1.Memo1MouseDown(Sender: TObject; Button: TMouseButton;  Shift: TShiftState; X, Y: Integer);begin  if DragDropCopyComplete(Memo1.Lines) then    Caption := 'Dropped';end;Then, at run time, drag Memo to some directory in Windows Explorer.

--- End quote ---

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.

Navigation

[0] Message Index

Go to full version