Platforms to show: All Mac Windows Linux Cross-Platform

/WinFrameworks/WinFileDialogObserver


Required plugins for this example: MBS WinFrameworks Plugin

You find this example project in your Plugins Download as a Xojo project file within the examples folder: /WinFrameworks/WinFileDialogObserver

This example is the version from Mon, 13th Sep 2020.

Project "WinFileDialogObserver.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
End Class
Class MainWindow Inherits Window
Control CheckEnable Inherits CheckBox
ControlInstance CheckEnable Inherits CheckBox
EventHandler Sub Action() MyWinFileDialogObserver.Enabled = Me.Value End EventHandler
End Control
Control OpenButton Inherits PushButton
ControlInstance OpenButton Inherits PushButton
EventHandler Sub Action() Dim dlg As New OpenDialog Dim f As FolderItem #If Not TargetLinux Then dlg.InitialDirectory = SpecialFolder.Documents #Else //open Home directory on linux dlg.InitialDirectory = SpecialFolder.Home #EndIf dlg.Title = "Select a Text file" Log "ShowModal..." f = dlg.ShowModal Log "ShowModal done" If f <> Nil Then //proceed normally Log "file: "+f.NativePath Else //User Cancelled Log "cancelled." End If End EventHandler
End Control
Control List Inherits Listbox
ControlInstance List Inherits Listbox
End Control
Control SaveButton Inherits PushButton
ControlInstance SaveButton Inherits PushButton
EventHandler Sub Action() Dim dlg As New SaveAsDialog Dim f As FolderItem dlg.InitialDirectory = SpecialFolder.Documents dlg.PromptText = "Prompt Text" dlg.SuggestedFileName = "Suggested Filename" dlg.Title = "Title Property" Log "ShowModal..." f = dlg.ShowModal Log "ShowModal done" If f <> Nil Then // file saved Log "file: "+f.NativePath Else // user canceled Log "cancelled." End If End EventHandler
End Control
EventHandler Sub Open() Observer = New MyWinFileDialogObserver End EventHandler
Sub Log(s as string) List.AddRow s List.ScrollPosition = list.ListCount End Sub
Property Observer As MyWinFileDialogObserver
End Class
MenuBar MainMenuBar
MenuItem FileMenu = "&File"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem EditSeparator1 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "#App.kEditClear"
MenuItem EditSeparator2 = "-"
MenuItem EditSelectAll = "Select &All"
End MenuBar
Class MyWinFileDialogObserver Inherits WinFileDialogObserverMBS
EventHandler Sub DidShowDialog(dialog as WinFileDialogMBS, Result as Integer) MainWindow.Log CurrentMethodName MainWindow.Log "Result: "+Str(result) End EventHandler
EventHandler Sub WillShowDialog(dialog as WinFileDialogMBS) MainWindow.Log CurrentMethodName dialog.Title = "Observer called" dialog.OptionForceShowHidden = True If dialog IsA WinFileSaveDialogMBS Then Dim d As WinFileSaveDialogMBS = WinFileSaveDialogMBS(dialog) // change suggested file name for save dialog d.FileName = "HelloWorld.txt" End If End EventHandler
End Class
End Project

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


The biggest plugin in space...