Faux Drag and Drop Icons
This script creates drag and drop icons/shortcuts with auto grid capability, size options, and spacing options. It's a more functional alternative to the standard DX drag and drop icon shortcuts.
'===INSTRUCTIONS=====
'Create "parent" object, accept drag and drop
'Create "temp_obj", parent="parent", child= yes...
'x/y = -50, set w/h, objecttype = shortcut...
'movement = locked
'===================
'Called when files are dropped onto object
Sub Object_OnDropFiles(files)
object.SetTimer 1, 100
End Sub
Sub Object_OnTimer1
object.KillTimer 1
setIcon
End Sub
Sub setIcon
On Error Resume Next
Set fso = CreateObject("Scripting.FileSystemObject")
'Give real icon object name
For Each elem In object.Children
If elem.name = "" Then
elem.name = "truicon"
Set truicon = DesktopX.Object("truicon")
End If
Next
If DesktopX.IsObject("truicon") = True Then
'Get number of faux icons
icongrp = DesktopX.GroupObjects("icongrp").count
'Set new faux icon name
newicon = "icon_" & icongrp + 1
'Clone faux icon template
Set tempobj = DesktopX.Object("temp_obj")
tempobj.clone newicon, tempobj.left, tempobj.top
'Set new faux icon information
DesktopX.Object(newicon).parent = DesktopX.Object("p")
DesktopX.Object(newicon).group = "icongrp"
DesktopX.Object(newicon).picture = truicon.picture
DesktopX.Object(newicon).command = truicon.command
DesktopX.Object(newicon).tooltiptext = fso.getbasename(DesktopX.Object(newicon).command)
'Delete real icon object
truicon.delete
'Get new faux icon count
lastobj = DesktopX.GroupObjects("icongrp").count
gap = 28 '--space between faux icons
'Arrange faux icons on grid
For x = 1 To lastobj
If x = 1 Then
DesktopX.Object("icon_" & x).move 10,10
Else
lastx = DesktopX.Object("icon_" & x-1).right + gap
lasty = DesktopX.Object("icon_" & x-1).top
If lastx => object.width - gap Then
lastx = 10
lasty = DesktopX.Object("icon_" & x-1).bottom + gap
End If
DesktopX.Object("icon_" & x).move lastx, lasty
End If
Next
Set fso = nothing
Set truicon = nothing
Set tempobj = nothing
Else
msgbox "Drag and drop not accepted; invalid file type."
End If
End Sub