You find this example project in your Plugins Download as a Xojo project file within the examples folder: /Win/Drag and Drop/Text Drop
Class App Inherits Application
Const kEditClear = "&Löschen"
Const kFileQuit = "Beenden"
Const kFileQuitShortcut = ""
End Class
MenuBar MenuBar1
MenuItem FileMenu = "&Ablage"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Bearbeiten"
MenuItem EditUndo = "&Rückgängig"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "&Ausschneiden"
MenuItem EditCopy = "&Kopieren"
MenuItem EditPaste = "&Einfügen"
MenuItem EditClear = "#App.kEditClear"
MenuItem UntitledMenu0 = "-"
MenuItem EditSelectAll = "&Alles auswählen"
End MenuBar
Class TextDropWindow Inherits Window
Control StaticText1 Inherits Label
ControlInstance StaticText1 Inherits Label
End Control
EventHandler Sub Open()
w = new TextDropTarget
dim e as integer = w.AttachToWindow(Self)
System.DebugLog "AttachToWindow: "+str(e)
End EventHandler
Property w As TextDropTarget
End Class
Class TextDropTarget Inherits WindowsDropTargetMBS
EventHandler Function DragEnter(dataObject as WinDataObjectMBS, keystate as integer, x as integer, y as integer, byref effect as integer) As integer
// does the dataobject contain data we want?
allowed = dataObject.HasText
if allowed then
// allow it
effect = DROPEFFECT_COPY
else
// deny
effect = DROPEFFECT_NONE
end if
Return S_OK
End EventHandler
EventHandler Function DragLeave() As integer
return S_OK
End EventHandler
EventHandler Function DragOver(keystate as integer, x as integer, y as integer, byref effect as integer) As integer
if allowed then
// allow it
effect = DROPEFFECT_COPY
else
// deny
effect = DROPEFFECT_NONE
end if
Return S_OK
End EventHandler
EventHandler Function Drop(dataObject as WinDataObjectMBS, keystate as integer, x as integer, y as integer, byref effect as integer) As integer
System.DebugLog "Inside drop event "+str(allowed)
if allowed then
// allow it
effect = DROPEFFECT_COPY
dim s as string = dataObject.GetText
System.DebugLog s
TextDropWindow.StaticText1.text = s
else
// deny
effect = DROPEFFECT_NONE
end if
Return S_OK
End EventHandler
Property allowed As Boolean
End Class