Recent

Author Topic: on form drag and drop file option  (Read 419 times)

Packs

  • Sr. Member
  • ****
  • Posts: 476
on form drag and drop file option
« on: February 14, 2025, 08:36:29 am »
On form there is drag and drop option it is working properly .

I have one form where on top of form lot of panel and memo component.

it is not working because form event can not raised .

how to achieve this 

cdbc

  • Hero Member
  • *****
  • Posts: 1946
    • http://www.cdbc.dk
Re: on form drag and drop file option
« Reply #1 on: February 14, 2025, 11:17:59 am »
Hi
Forward the event to the components in question...
Regards Benny
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE5 -> FPC 3.2.2 -> Lazarus 3.6 up until Jan 2024 from then on it's both above &: KDE5/QT5 -> FPC 3.3.1 -> Lazarus 4.99

Packs

  • Sr. Member
  • ****
  • Posts: 476
Re: on form drag and drop file option
« Reply #2 on: February 14, 2025, 11:21:36 am »
Code: Pascal  [Select][+][-]
  1. procedure Tfrminward.FormDropFiles(Sender: TObject; const FileNames: array of string);
  2. begin
  3.   if Length(FileNames) > 1 then
  4.   begin
  5.     ShowMessage('Select one file');
  6.     Exit;
  7.   end;
  8.  
  9.   Opendlg_inward.FileName := FileNames[0];
  10. end;
  11.  

form FormDropFiles event should run.

it is get protected if you have panel or other components in form.

cdbc

  • Hero Member
  • *****
  • Posts: 1946
    • http://www.cdbc.dk
Re: on form drag and drop file option
« Reply #3 on: February 14, 2025, 11:41:59 am »
Hi
If your whole form is covered with components, I've found it easiest to just let the /drop/ event-handlers of said components, just point to the same one - namely the one you have for the form...
Regards Benny
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE5 -> FPC 3.2.2 -> Lazarus 3.6 up until Jan 2024 from then on it's both above &: KDE5/QT5 -> FPC 3.3.1 -> Lazarus 4.99

Packs

  • Sr. Member
  • ****
  • Posts: 476
Re: on form drag and drop file option
« Reply #4 on: February 14, 2025, 11:47:56 am »
in that case I have to write event for all component .

it should be simple user will drag and drop any where , my form dragfile event should trigger .

cdbc

  • Hero Member
  • *****
  • Posts: 1946
    • http://www.cdbc.dk
Re: on form drag and drop file option
« Reply #5 on: February 14, 2025, 12:06:37 pm »
Hi
No, just point all the components' handlers to the one you have written for the form, they have the same signature. You can do that in the Object Inspector.
Regards Benny
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE5 -> FPC 3.2.2 -> Lazarus 3.6 up until Jan 2024 from then on it's both above &: KDE5/QT5 -> FPC 3.3.1 -> Lazarus 4.99

Packs

  • Sr. Member
  • ****
  • Posts: 476
Re: on form drag and drop file option
« Reply #6 on: February 14, 2025, 12:09:27 pm »
all component is having different signature .

on formdrag event accept file other all accepting x,y position or string

cdbc

  • Hero Member
  • *****
  • Posts: 1946
    • http://www.cdbc.dk
Re: on form drag and drop file option
« Reply #7 on: February 14, 2025, 12:31:29 pm »
...Then Google is your friend  ...I guess.

eta: At least you need someone more knowledgeable than me, regarding the intricacies of the LCL.
« Last Edit: February 14, 2025, 12:35:54 pm by cdbc »
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE5 -> FPC 3.2.2 -> Lazarus 3.6 up until Jan 2024 from then on it's both above &: KDE5/QT5 -> FPC 3.3.1 -> Lazarus 4.99

Packs

  • Sr. Member
  • ****
  • Posts: 476
Re: on form drag and drop file option
« Reply #8 on: February 14, 2025, 12:46:58 pm »
Ok Sir 👍

 

TinyPortal © 2005-2018