Recent

Author Topic: [Solved] Drag and drop on closed application  (Read 4301 times)

jwdietrich

  • Hero Member
  • *****
  • Posts: 1036
    • formatio reticularis
[Solved] Drag and drop on closed application
« on: March 16, 2016, 10:06:08 pm »
The attached demo droplet works well on Mac OS X, since it not only opens text files that are dropped on its form, but it also opens them, if they are dropped onto the icon of the application, even before it has been started.

Unfortunately, the latter function doesn't seem to be supported in Windows widgetsets. If I drop a text file onto the form of the (running) program all is fine, but if I drop it onto its icon before the application runs nothing happens.

What do I have to do to enable drag & drop operations that automatically start the program and relay a path to files that are dropped onto the icon?

Edit: Marked as solved.
« Last Edit: March 19, 2017, 01:56:11 pm by jwdietrich »
function GetRandomNumber: integer; // xkcd.com
begin
  GetRandomNumber := 4; // chosen by fair dice roll. Guaranteed to be random.
end;

http://www.formatio-reticularis.de

Lazarus 2.0.6 | FPC 3.0.4 | PPC, Intel, ARM | macOS, Windows, Linux

Bart

  • Hero Member
  • *****
  • Posts: 3539
    • Bart en Mariska's Webstek
Re: Drag and drop on closed application
« Reply #1 on: March 17, 2016, 01:01:57 am »
AFAIK dropping files on a shortcut to an application in Windows will invoke the program with filename(s) as their paramstrings.

So then at program start chech those parameters and act upon it.

Bart

Mando

  • Full Member
  • ***
  • Posts: 181
Re: Drag and drop on closed application
« Reply #2 on: March 17, 2016, 12:35:00 pm »
HI.
Try this. It works for windows.

regarads.

jwdietrich

  • Hero Member
  • *****
  • Posts: 1036
    • formatio reticularis
Re: Drag and drop on closed application
« Reply #3 on: March 17, 2016, 01:33:56 pm »
Thanks.@Mando, I have simultaneously implemented Bart's suggestion, and my solution is similar to yours, see attached file. The only difference is that you read the ParamStrings in the main unit, while my program does it in the form's unit. I think that for large projects your solution may be the better one.

Thanks again.
function GetRandomNumber: integer; // xkcd.com
begin
  GetRandomNumber := 4; // chosen by fair dice roll. Guaranteed to be random.
end;

http://www.formatio-reticularis.de

Lazarus 2.0.6 | FPC 3.0.4 | PPC, Intel, ARM | macOS, Windows, Linux