McBasic™Get McBasic™ ↗
Build 881
Components · Nonvisual component
CommonDialog component icon

CommonDialog

Open file, save, folder, color, font and print-related dialogs.

12 properties0 events7 methods

Use it in a Form#

A cancelled dialog is a normal outcome. Read the result before performing a file operation, and never turn an empty selection into a default path silently. A picker grants the user a choice; it does not mean the later read or write cannot fail.

Add CommonDialog to the component tray and name it dlgCommon for this example:

PropertyExample value
Title"McBasic CommonDialog"
Filter"Text files|*.txt;*.md"
FileName"notes.txt"
Color"#1565C0"
Font"System|13|Regular|Normal"
PrinterName""
PaperName""
PageOrientation"Portrait"
PageWidth612
PageHeight792

Use the full lesson for the owner’s initialization code and its complete layout.

Properties#

Contract defaults are shown below. Where a new control has a different Designer starting value, that value is listed separately.

Title

StringDefault: ""

Caption for the next dialog. Empty uses the action-specific system caption.

Filter

StringDefault: ""

File filter as Description|*.ext;*.ext. Empty permits all file types.

FileName

StringDefault: ""

Selected absolute file or folder path; for Save it also supplies the suggested name.

Color

StringDefault: ""

Selected color as #RRGGBB or #AARRGGBB. Empty uses the current system accent initially.

Font

StringDefault: ""

Selected font as Family|Size|Regular/Bold|Normal/Italic. Empty uses the system font initially.

PrinterName

StringDefault: ""

Selected printer name. Empty uses the current system printer.

PaperName

StringDefault: ""

Selected paper name. Empty uses the current system paper.

PageOrientation

StringDefault: "Portrait"

Page orientation: Portrait or Landscape.

PageWidth

DoubleDefault: 612

Selected paper width in points.

Range: 1 to 100000.

PageHeight

DoubleDefault: 792

Selected paper height in points.

Range: 1 to 100000.

Cancelled

BooleanDefault: FalseRead only in BASICNot in InspectorNot serialized

Read-only state set when the user cancels the last dialog; platform errors raise a McBasic™ error instead.

LastAction

StringDefault: ""Read only in BASICNot in InspectorNot serialized

Read-only name of the last completed or cancelled dialog action.

Events and parameters#

Replace control with the object’s Name when creating a handler. ByRef arguments may be changed by your handler; ByVal arguments report an input value.

No events are declared.

Methods#

ShowOpen

Method contract
Sub ShowOpen()

Call on your instance: dlgCommon.ShowOpen.

ShowSave

Method contract
Sub ShowSave()

Call on your instance: dlgCommon.ShowSave.

ShowFolder

Method contract
Sub ShowFolder()

Call on your instance: dlgCommon.ShowFolder.

ShowColor

Method contract
Sub ShowColor()

Call on your instance: dlgCommon.ShowColor.

ShowFont

Method contract
Sub ShowFont()

Call on your instance: dlgCommon.ShowFont.

ShowPrinter

Method contract
Sub ShowPrinter()

Call on your instance: dlgCommon.ShowPrinter.

ShowPageSetup

Method contract
Sub ShowPageSetup()

Call on your instance: dlgCommon.ShowPageSetup.

Source baseline 20f4bfed6b · Build manifest