TBMANLIB_Dialog Package
Author: woeoio
A twinBASIC package with one class, cDialog, that shows the Windows Open, Save As and Browse For Folder dialogs, builds the file-type filters of the first two, splits a file path into folder, name and extension, and opens a file in the program that Windows associates with it. The property names follow VB6’s CommonDialog control. The CommonDialog class of the VBComDlg package is the fuller alternative, with flags, a filter index, cancel errors and the Color, Font and Print dialogs.
Classes
- cDialog – shows the Open, Save As and Browse For Folder dialogs, builds file filters, splits file paths and opens files.
Properties (cDialog)
- CreatePrompt – asks before the Open dialog accepts a file that does not exist.
- DefaultExt – the extension that Windows adds to a file name typed without one.
- DialogTitle – the text that the dialogs show as their title.
- FileMustExist – lets the Open dialog accept only the name of an existing file.
- FileName – the file name shown when a dialog opens, and the path that the last Open or Save As dialog returned.
- Filter – the file-type list of the Open and Save As dialogs, as pairs of a description and a pattern.
- HideReadOnly – hides the read-only choice of the Open dialog.
- InitialDir – the folder in which the Open and Save As dialogs start.
- MultiSelect – lets the Open dialog select more than one file.
- NewDialogStyle – selects the resizable Browse For Folder dialog with an edit box.
- NoChangeDir – keeps the current folder of the program as it was.
- OverwritePrompt – asks before the Save As dialog accepts the name of an existing file.
- PathMustExist – lets the Open and Save As dialogs accept only paths that exist.
- ReadOnly – sets the read-only flag of the Open dialog, which has no visible effect.
Methods (cDialog)
- AddFilter – appends a description and a pattern to the filter.
- ClearFilter – empties the filter.
- GetFileExtension – returns the part of a path from its last period.
- GetFileName – returns the part of a path after its last backslash.
- GetFileNameWithoutExt – returns the file name of a path without its extension.
- GetFilePath – returns the part of a path before its last backslash.
- OpenFile – runs a shell verb, by default
open, on a file or a program. - Reset – restores every property to its starting value.
- SelectAndOpenFile – shows the Open dialog and opens the chosen file or files.
- SetCodeFilters – replaces the filter with one for source code files.
- SetCommonFilters – replaces the filter with Text Files and All Files.
- SetDocumentFilters – replaces the filter with one for office documents.
- SetImageFilters – replaces the filter with one for image files.
- ShowBrowseForFolder – shows the Browse For Folder dialog and returns the chosen folder.
- ShowOpen – shows the Open dialog and returns the chosen file.
- ShowSave – shows the Save As dialog and returns the chosen file name.