Lazarus
Home
Help
TinyPortal
Search
Login
Register
Lazarus
»
Forum
»
Programming
»
General
»
on form drag and drop file option
Free Pascal
Website
Downloads
Wiki
Documentation
Bugtracker
Mailing List
Lazarus
Website
Downloads (Laz+FPC)
Packages (OPM)
FAQ
Wiki
Documentation (RTL/FCL/LCL)
Bugtracker
CCR Bugs
GIT
Mailing List
Other languages
Foundation
Website
Useful Wiki Links
Project Roadmap
Getting the Source
Screenshots
How to use the forum
About donations (wiki)
Bookstore
Computer Math and Games in Pascal
(preview)
Lazarus Handbook
Search
Advanced search
Recent
IDE crashes and takes so ...
by
Martin_fr
[
Today
at 08:49:04 pm]
Newbie in Web Programming...
by
Nicole
[
Today
at 08:44:50 pm]
multitask question
by
Dzandaa
[
Today
at 08:33:26 pm]
Compiling Lazarus from so...
by
TRon
[
Today
at 07:55:37 pm]
Macos Sequoia Lazarus 3.8...
by
ChrisR
[
Today
at 07:34:39 pm]
Planet generator(raylib)
by
Lulu
[
Today
at 07:29:54 pm]
Good online resource to l...
by
Thaddy
[
Today
at 06:41:21 pm]
TPaintbox picture disappe...
by
TRon
[
Today
at 06:31:33 pm]
login_tty and openpty are...
by
Fred vS
[
Today
at 06:19:14 pm]
Minimal IPC approach?
by
duralast
[
Today
at 05:41:36 pm]
ShowModal has a bug in Li...
by
TRon
[
Today
at 04:14:31 pm]
BGRABitmap can't compile
by
Khrys
[
Today
at 03:43:59 pm]
Why isn't Lazarus / Free ...
by
silvercoder70
[
Today
at 02:46:40 pm]
Lazarus Release Candidate...
by
dbannon
[
Today
at 02:02:57 pm]
[solved] is there a non v...
by
d2010
[
Today
at 02:01:07 pm]
Linux Laz Packages have i...
by
dbannon
[
Today
at 01:56:35 pm]
Is there a chart displayi...
by
simone
[
Today
at 10:19:27 am]
How to re use a process
by
Thaddy
[
Today
at 10:10:46 am]
Helping beginners
by
Thaddy
[
Today
at 09:15:26 am]
[SOLVED] Application stil...
by
d2010
[
Today
at 07:01:19 am]
TListView - please advis...
by
TRon
[April 29, 2025, 09:49:00 pm]
$CODEPAGE + LCL = Incorre...
by
Thaddy
[April 29, 2025, 06:47:53 pm]
SOLVED: Warning: "crtbegi...
by
Thaddy
[April 29, 2025, 06:43:37 pm]
Randomally generated code
by
Thaddy
[April 29, 2025, 06:41:17 pm]
TStringGrid: what is the ...
by
jcmontherock
[April 29, 2025, 05:39:26 pm]
« previous
next »
Print
Pages: [
1
]
Author
Topic: on form drag and drop file option (Read 656 times)
Packs
Sr. Member
Posts: 486
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
Logged
cdbc
Hero Member
Posts: 2111
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
Logged
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: 486
Re: on form drag and drop file option
«
Reply #2 on:
February 14, 2025, 11:21:36 am »
Code: Pascal
[Select]
[+]
[-]
procedure
Tfrminward
.
FormDropFiles
(
Sender
:
TObject
;
const
FileNames
:
array
of
string
)
;
begin
if
Length
(
FileNames
)
>
1
then
begin
ShowMessage
(
'Select one file'
)
;
Exit
;
end
;
Opendlg_inward
.
FileName
:
=
FileNames
[
0
]
;
end
;
form FormDropFiles event should run.
it is get protected if you have panel or other components in form.
Logged
cdbc
Hero Member
Posts: 2111
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
Logged
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: 486
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 .
Logged
cdbc
Hero Member
Posts: 2111
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
Logged
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: 486
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
Logged
cdbc
Hero Member
Posts: 2111
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
»
Logged
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: 486
Re: on form drag and drop file option
«
Reply #8 on:
February 14, 2025, 12:46:58 pm »
Ok Sir 👍
Logged
wp
Hero Member
Posts: 12773
Re: on form drag and drop file option
«
Reply #9 on:
March 21, 2025, 07:19:24 pm »
See
https://forum.lazarus.freepascal.org/index.php/topic,70589.msg550415.html#msg550415
for a workaround based on embedded forms.
Logged
Remy Lebeau
Hero Member
Posts: 1504
Re: on form drag and drop file option
«
Reply #10 on:
March 21, 2025, 07:32:14 pm »
UI controls don't have events for dropping files on them. The
OnDragDrop
and similar events are meant for drag&dropping
other UI controls
onto each other. If you want to accept a file drop onto a child UI control of a Form, then you have to manually register the drag&drop handler yourself. For instance, on Windows, using either
DragAcceptFiles()
or
RegisterDragDrop()
, and then handling the relevant callback.
Logged
Remy Lebeau
Lebeau Software
- Owner, Developer
Internet Direct (Indy)
- Admin, Developer (
Support forum
)
Print
Pages: [
1
]
« previous
next »
Lazarus
»
Forum
»
Programming
»
General
»
on form drag and drop file option
TinyPortal
© 2005-2018