Platforms to show: All Mac Windows Linux Cross-Platform
Required plugins for this example: MBS MacBase Plugin, MBS Main Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /Win/Clipboard/ClipboardSaver
This example is the version from Wed, 15th May 2012.
Project "ClipboardSaver.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Löschen"
Const kFileQuit = "Beenden"
Const kFileQuitShortcut = ""
End Class
Class Window1 Inherits Window
Control BevelButton1 Inherits BevelButton
ControlInstance BevelButton1 Inherits BevelButton
EventHandler Sub Action()
stack.Append new ClipboardSaver
End EventHandler
End Control
Control BevelButton2 Inherits BevelButton
ControlInstance BevelButton2 Inherits BevelButton
EventHandler Sub Action()
dim c as ClipboardSaver = stack.pop
c.restore
End EventHandler
End Control
Control List Inherits Listbox
ControlInstance List Inherits Listbox
End Control
Control BevelButton3 Inherits BevelButton
ControlInstance BevelButton3 Inherits BevelButton
EventHandler Sub Action()
List.DeleteAllRows
#if TargetWin32
dim w as new WindowsClipboardMBS
dim types(-1) as integer = w.ClipboardFormats
for each type as integer in types
dim d as string = w.GetData(type)
dim n as string = GetNameOfType(w.GetClipboardFormatName(type), type)
if len(n)>0 then
List.AddRow str(type)+" ("+n+")"
else
List.AddRow str(type)
end if
List.Cell(List.LastIndex,1)=w.GetData(type)
next
#elseif TargetMacOS
dim p as new NSPasteboardMBS
dim types(-1) as string = p.types
for each type as string in types
List.AddRow type
List.Cell(List.LastIndex,1)=p.dataForType(type)
next
#endif
End EventHandler
End Control
Function GetNameOfType(n as string, type as integer) As string
if len(n)>0 then
Return n
end if
Select case type
case WindowsClipboardMBS.kTypeText
Return "Text"
case WindowsClipboardMBS.kTypeBitmap
Return "Bitmap"
case WindowsClipboardMBS.kTypeMetaFilePict
Return "MetaFilePict"
case WindowsClipboardMBS.kTypeSylk
Return "Sylk"
case WindowsClipboardMBS.kTypeDIF
Return "DIF"
case WindowsClipboardMBS.kTypeTIFF
Return "TIFF"
case WindowsClipboardMBS.kTypeOEMText
Return "OEMText"
case WindowsClipboardMBS.kTypeDIB
Return "DIB"
case WindowsClipboardMBS.kTypePalette
Return "Palette"
case WindowsClipboardMBS.kTypePenData
Return "PenData"
case WindowsClipboardMBS.kTypeRIFF
Return "RIFF"
case WindowsClipboardMBS.kTypeWAVE
Return "WAVE"
case WindowsClipboardMBS.kTypeUnicodeText
Return "UnicodeText"
case WindowsClipboardMBS.kTypeENHMetaFile
Return "ENHMetaFile"
case WindowsClipboardMBS.kTypeHDROP
Return "HDROP"
case WindowsClipboardMBS.kTypeLocale
Return "Locale"
case WindowsClipboardMBS.kTypeDIBV5
Return "DIBV5"
end Select
End Function
Property stack() As ClipboardSaver
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 ClipboardSaver
Sub Constructor()
#if TargetWin32
dim w as new WindowsClipboardMBS
dim types(-1) as integer = w.ClipboardFormats
for each type as integer in types
dim d as string = w.GetData(type)
me.wtype.Append type
me.data.Append d
next
#elseif TargetMacOS
dim p as new NSPasteboardMBS
dim types(-1) as string = p.types
for each type as string in types
me.mtype.Append type
me.data.Append p.dataForType(type)
next
#endif
End Sub
Sub Restore()
#if TargetWin32
dim w as new WindowsClipboardMBS
w.Clear
dim u as integer = UBound(Data)
for i as integer = 0 to u
call w.SetData(wtype(i), data(i))
next
#elseif TargetMacOS
dim p as new NSPasteboardMBS
call p.declareTypes(mtype)
dim u as integer = UBound(Data)
for i as integer = 0 to u
p.dataForType(mtype(i))=data(i)
next
#endif
End Sub
Property data() As string
Property mtype() As string
Property wtype() As Integer
End Class
End Project
The items on this page are in the following plugins: MBS Win Plugin.