Xojo Conferences
MBSSep2018MunichDE
XDCMay2019MiamiUSA

Platforms to show: All Mac Windows Linux Cross-Platform

/Win/Drag and Drop/Attachment Drop from Outlook
Function:
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/Attachment Drop from Outlook
This example is the version from Sat, 11th Dec 2015.
Project "Attachment Drop from Outlook.rbp"
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 FileDropWindow Inherits Window
Control List Inherits Listbox
ControlInstance List Inherits Listbox
EventHandler Sub DoubleClick() MsgBox me.Cell(me.ListIndex, 0) End EventHandler
End Control
EventHandler Sub Open() w = new FileDropTarget dim e as integer = w.AttachToWindow(Self) System.DebugLog "AttachToWindow: "+str(e) End EventHandler
Property w As FileDropTarget
End Class
Class FileDropTarget 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? System.DebugLog CurrentMethodName allowed = dataObject.hasPaths or dataObject.HasFileDescriptors or dataObject.HasFileName 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 System.DebugLog CurrentMethodName 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) FileDropWindow.List.DeleteAllRows FileDropWindow.List.AddRow "Formats: "+Join(dataObject.Formats,", ") if allowed then // allow it effect = DROPEFFECT_COPY dim files(-1) as FolderItem = dataObject.GetPaths for each f as FolderItem in files // we got a file you can use like any other file (e.g. copy) FileDropWindow.List.AddRow "Path """+f.AbsolutePath+"""" next dim des(-1) as WindowsFileDescriptorMBS = dataObject.GetFileDescriptors for each d as WindowsFileDescriptorMBS in des // we got file descriptions. Some metadata and the data. No path. dim data as string = dataObject.GetFileContents(d.Index) FileDropWindow.List.AddRow "File """+d.FileName+""" with "+str(lenb(data))+" bytes data." FileDropWindow.List.AddRow "ClassID: " + d.ClassID FileDropWindow.List.AddRow "Flags: " + str(d.Flags) FileDropWindow.List.AddRow "FileAttributes: " + str(d.FileAttributes) next dim s as string = dataObject.GetText if s <> "" then FileDropWindow.List.AddRow "Text with "+str(len(s))+" Characters." FileDropWindow.List.AddRow s end if if dataObject.HasFileName then FileDropWindow.List.AddRow "FileName: "+dataObject.GetFileName end if else // deny effect = DROPEFFECT_NONE end if Return S_OK End EventHandler
Property allowed As Boolean
End Class
End Project

See also:

Feedback, Comments & Corrections

The items on this page are in the following plugins: MBS Win Plugin.





Links
MBS Xojo Chart Plugins