Platforms to show: All Mac Windows Linux Cross-Platform
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/Preview Handler
This example is the version from Mon, 10th Sep 2023.
Project "Preview Handler.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Löschen"
Const kFileQuit = "Beenden"
Const kFileQuitShortcut = ""
End Class
Class MainWindow Inherits Window
Control Label1 Inherits Label
ControlInstance Label1 Inherits Label
End Control
Control PHList Inherits Listbox
ControlInstance PHList Inherits Listbox
EventHandler Sub Change()
PushButton1.Enabled = me.ListIndex >= 0
End EventHandler
End Control
Control PushButton1 Inherits PushButton
ControlInstance PushButton1 Inherits PushButton
EventHandler Sub Action()
if w<>Nil then
w.unload
w = nil
end if
dim f as FolderItem = GetOpenFolderItem("")
if f = nil then Return
dim id as string = PHList.Cell(PHList.ListIndex, 0)
w = New WindowsPreviewHandlerMBS(id)
if w.Lasterror = 0 then
w.InitWithFile(F)
If w.Lasterror = 0 Then
// old way to specify rectangle in parent window
'Dim scale As Double = Screen(0).ScaleFactor
'w.SetWindow(Self, canvas1.Left*scale, canvas1.top*scale, canvas1.Width*scale, canvas1.Height*scale)
// new way
w.SetWindow(canvas1)
If w.Lasterror = 0 Then
w.DoPreview
if w.Lasterror = 0 then
// ok
else
MsgBox "Failed to run preview: "+w.LasterrorString
end if
else
MsgBox "Failed to set window: "+w.LasterrorString
end if
else
MsgBox "Failed to load file: "+w.LasterrorString
end if
else
MsgBox "Failed to load preview handler: "+w.LasterrorString
end if
End EventHandler
End Control
Control Label2 Inherits Label
ControlInstance Label2 Inherits Label
End Control
Control Canvas1 Inherits Canvas
ControlInstance Canvas1 Inherits Canvas
End Control
EventHandler Sub Close()
if w<>Nil then
w.unload
end if
End EventHandler
EventHandler Sub Open()
ListHandlers
End EventHandler
EventHandler Sub Resized()
if w<>nil then
w.SetRect(canvas1.Left, canvas1.top, canvas1.Width, canvas1.Height)
end if
End EventHandler
EventHandler Sub Resizing()
if w<>nil then
w.SetRect(canvas1.Left, canvas1.top, canvas1.Width, canvas1.Height)
end if
End EventHandler
Sub ListHandlers()
PHList.DeleteAllRows
Dim r As New RegistryItem("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\PreviewHandlers", False)
dim c as integer = r.KeyCount-1
for i as integer = 0 to c
PHList.AddRow r.Name(i)
PHList.Cell(PHList.LastIndex,1) = r.Value(r.Name(i))
next
End Sub
Property w As WindowsPreviewHandlerMBS
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
End Project
The items on this page are in the following plugins: MBS Win Plugin.