Gfa_OnDropInl Event

Syntax

Sub Gfa_OnDropInl(ParamArray p())

Description

When the Sub Gfa_OnDropInl(ParamArray p()) exists the ':Files' tab in the sidebar will become a drag and drop window. When one or more files are dragged from the Explorer to the ':Files' window the Gfa_OnDropInl sub is invoked. The ParamArray p() contains the strings with filenames that are dropped in the operation.

Example

Add resources using drag 'n drop.

When a GLL contains the Gfa_OnDropInl sub, the drag and drop facility of the :Files tab is enabled. The Gfa_OnDropInl takes one parameter: a ParamArray containing the list of files to add.

 

Sub Gfa_OnDropInl(ParamArray p())

Local Int i

For i = LBound(p) To UBound(p)

dropfile p(i)

Next

End Sub

 

Sub dropfile(f$)

Debug "Dropped file " + f

Local a$, i%

Try

a = f

If(FileLen(f) > 8192)

If MsgBox("File length " & f & " =" & FileLen(f$) & "Bytes"#10"Copy anyway?", _

MB_YESNO) == IDNO Then Exit Sub

EndIf

i% = RInStr(f$, "\")

If i%

a = Mid(f, i + 1)

i% = RInStr(a, ".")

If i > 1 Then a = Left(a, i - 1)

a = ":" & a

If Exist(a)

// InlFile exists

i = MsgBox("InlFile " & a & " exists" #10 "Overwrite " & f & "?", MB_YESNOCANCEL)

If i = IDCANCEL Then Exit Sub // nothing to do

If i = IDYES Then Gfa_CopyFile "", a : Gfa_CopyFile f, a : Exit Sub

For i = 0 To 99

If !Exist(a & Dec(i))

Gfa_CopyFile f, a & Dec(i)

Exit Sub

EndIf

Next

MsgBox "Too much copies."

Exit Sub

EndIf

Gfa_CopyFile f, a

EndIf

Catch

MsgBox "Error creating a copy of " & f

EndCatch

End Sub

The dropfile sub is called for each file in the ParamArray. First the size of the file is tested, because including resources larger then 8192 bytes might not be advisable. A confirmation is asked, therefore. Then the filename is obtained from the full path name and section without the extension is used as the ':File' name. When the ':File' exists in the inline section, you'll be asked to delete it first. If OK the resource is deleted from memory and the new file is added.

Remarks

See Also

Gfa_CopyFile, Gfa_InlFileName

{Created by Sjouke Hamstra; Last updated: 07/07/2022 by James Gaite; Other Contributors: Jean-Marie Melanson}