Recent

Author Topic: Drag file to another application  (Read 6652 times)

havezet

  • New Member
  • *
  • Posts: 26
Drag file to another application
« on: November 29, 2011, 09:35:33 am »
In my application I've got a thumbnail image that represents a file. I now want to drag this thumbnail and drop it to another location in the OS (e.g. an application on the Dock, or to the desktop). Is there a way to do this in Lazarus? Any pointers are welcome.

havezet

  • New Member
  • *
  • Posts: 26
Re: Drag file to another application
« Reply #1 on: December 18, 2011, 09:49:21 am »
No replies? Doesn't seem like a very exotic question...

mica

  • Full Member
  • ***
  • Posts: 196

felipemdc

  • Administrator
  • Hero Member
  • *
  • Posts: 3538
Re: Drag file to another application
« Reply #3 on: December 18, 2011, 10:34:18 pm »
Strange, there it is written that drag-and-drop between applications works only between LCL applications. I never knew that, and I don't know if it is really like that. My major applications do not need this feature, so I never studied it, although it looks interresting.

So basically if that is true to do drag&drop to/from non-LCL applications you would need to either extend the LCL to support it (implementing in each widgetset that you need via operating system calls) or use operating system APIs directly to do it.

Shebuka

  • Sr. Member
  • ****
  • Posts: 429

prof7bit

  • Full Member
  • ***
  • Posts: 163
Re: Drag file to another application
« Reply #5 on: August 26, 2012, 12:23:17 am »
In my application I've got a thumbnail image that represents a file. I now want to drag this thumbnail and drop it to another location in the OS (e.g. an application on the Dock, or to the desktop). Is there a way to do this in Lazarus? Any pointers are welcome.

I made a component, its still very new (not thoroughly debugged yet) but it already allows dragging of files and/or text/plain content to other applications. It currently works (or is supposed to work) on Win32, Gtk2 and Qt. you can find it here: https://github.com/prof7bit/NativeDragDrop. If you still need it then give it a try, it has the same license as LCL itself.

Edit: I just notticed that this is the OS X subdivision of the forum. (This Thread came up as #1 after a google search for the topic and I did not notice that it was an OS X question). My component is intended to work on as many widgetsets as possible, I have implemented win32, Gtk and Qt myself but I cannot implement it for Carbon or Cocoa because I simply do not own a Mac, here I need some help from a native Mac programmer, maybe somebody here can contribute some code for the Mac.
« Last Edit: August 27, 2012, 12:19:56 pm by prof7bit »

staratel20

  • Full Member
  • ***
  • Posts: 218
Re: Drag file to another application
« Reply #6 on: September 22, 2025, 01:41:56 pm »
I tried to install your component(Windows 11, Lazarus IDE v3.6) but when I clicked the "Compile" button, I got the following error message:

dragdropwin32.pas(102,17) Error: No matching implementation for interface method "SetData(const tagFORMATETC;var TagSTGMEDIUM;LongBool):LongInt; StdCall;" found
Windows 7 SP1 x64, FPC 3.0.0, Lazarus from trunk: http://svn.freepascal.org/svn/lazarus/trunk

CountIdentity, ModeClassName - good property naming
IdentityCount,  ClassNameMode  - bad property naming

staratel20

  • Full Member
  • ***
  • Posts: 218
Re: Drag file to another application
« Reply #7 on: September 22, 2025, 09:27:27 pm »
Here is a couple of fixes and a test example, now it works. Hope you'll commit it ;)
Windows 7 SP1 x64, FPC 3.0.0, Lazarus from trunk: http://svn.freepascal.org/svn/lazarus/trunk

CountIdentity, ModeClassName - good property naming
IdentityCount,  ClassNameMode  - bad property naming

 

TinyPortal © 2005-2018