Platforms to show: All Mac Windows Linux Cross-Platform
/Win/Drag and Drop/Picture Drop on control
Required plugins for this example: MBS Win Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /Win/Drag and Drop/Picture Drop on control
This example is the version from Sun, 10th Dec 2016.
Project "Picture Drop on control.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Löschen"
Const kFileQuit = "Beenden"
Const kFileQuitShortcut = ""
EventHandler Sub Open()
if not TargetWin32 then
MsgBox "This example needs Windows."
end if
End EventHandler
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 PictureDropTarget 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.hasPicture
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
PictureDropWindow.Canvas2.Backdrop = dataObject.GetPicture
else
// deny
effect = DROPEFFECT_NONE
end if
Return S_OK
End EventHandler
Property allowed As Boolean
End Class
Class PictureDropWindow Inherits Window
Control StaticText1 Inherits Label
ControlInstance StaticText1 Inherits Label
End Control
Control Canvas2 Inherits Canvas
ControlInstance Canvas2 Inherits Canvas
EventHandler Sub Open()
me.Backdrop = new Picture(100,100,32)
w = new PictureDropTarget
dim e as integer = w.AttachToControl(me)
System.DebugLog "AttachToControl: "+str(e)
End EventHandler
End Control
Property w As PictureDropTarget
End Class
End Project
See also:
- /Win/Drag and Drop/Attachment Drop from Outlook
- /Win/Drag and Drop/File Drag
- /Win/Drag and Drop/File Drag Multi
- /Win/Drag and Drop/File Drop
- /Win/Drag and Drop/Folder Drag
- /Win/Drag and Drop/Picture Drag
- /Win/Drag and Drop/Picture Drag with Mask
- /Win/Drag and Drop/Picture Drop
- /Win/Drag and Drop/Text Drag
- /Win/Drag and Drop/Text Drop
The items on this page are in the following plugins: MBS Win Plugin.