Xojo Conferences

Platforms to show: All Mac Windows Linux Cross-Platform

/Util/OpenDialog with Filter
Required plugins for this example: MBS Util Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /Util/OpenDialog with Filter
This example is the version from Sun, 17th Mar 2012.
Project "OpenDialog with Filter.rbp"
MenuBar Menu
MenuItem UntitledMenu3 = ""
MenuItem UntitledMenu2 = "File"
MenuItem FileQuit = "Quit"
MenuItem UntitledMenu0 = "Edit"
MenuItem EditUndo = "Undo"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "Cut"
MenuItem EditCopy = "Copy"
MenuItem EditPaste = "Paste"
MenuItem EditClear = "Clear"
End MenuBar
Class App Inherits Application
EventHandler Sub Open() dim o as MyOpenDialogMBS dim i,c as integer dim f as FolderItem dim t as OpenDialogFileTypeMBS o=new MyOpenDialogMBS o.ShowHiddenFiles=true o.PromptText="Select one or more files:" o.MultipleSelection=false o.ActionButtonLabel="Open files" o.CancelButtonLabel="no, thanks." o.WindowTitle="This is a window title." o.ClientName="Client Name?" if TargetWin32 then // On Windows, use the Filetype popup, on Mac the event t=new OpenDialogFileTypeMBS t.Name="JPEG files" // for Windows only t.Extension="*.JPG" // Windows only o.AddType t end if o.ShowDialog c=o.FileCount if c>0 then for i=0 to c-1 f=o.Files(i) FileList.List.AddRow f.AbsolutePath next else // MsgBox "no file was selected." quit end if End EventHandler
End Class
Class FileList Inherits Window
Control List Inherits Listbox
ControlInstance List Inherits Listbox
End Control
End Class
Class MyOpenDialogMBS Inherits OpenDialogMBS
EventHandler Function FilterItem(file as folderitem, filterMode as integer) As boolean #pragma disableautowaitcursor if not file.Directory and right(file.Name,4)<>".JPG" and right(file.Name,5)<>".JPEG" and file.MacType<>"JPEG" then Return true // hide them end if End EventHandler
End Class
End Project

See also:

Feedback, Comments & Corrections

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

MBS Xojo Plugins