Dialog Controls
The Dialogs tab provides non-visual components that invoke standard OS dialog boxes. Drop them on a form and call their Execute() method to display the native dialog.
TOpenDialog CT_OPENDIALOG = 40
Standard file open dialog. Allows the user to browse and select one or more files to open.
| Property | Type | Default | Description |
cFileName | String | "" | Selected file path (after Execute) |
cFilter | String | "All files (*.*)|*.*" | File type filter (pipe-delimited pairs) |
nFilterIndex | Numeric | 1 | Default filter index |
cTitle | String | "Open" | Dialog title bar text |
cInitialDir | String | "" | Starting directory |
cDefaultExt | String | "" | Default file extension |
lMultiSelect | Logical | .F. | Allow selecting multiple files |
aFileNames | Array | {} | Selected files (when multi-select) |
| Event | Category | Description |
OnClose | Action | Dialog closed (after user selects or cancels) |
| Method | Returns | Description |
Execute() | Logical | Shows the dialog. Returns .T. if user selected a file, .F. if cancelled. |
| Platform | Native Dialog |
| Windows | GetOpenFileName() / IFileOpenDialog |
| macOS | NSOpenPanel |
| Linux | GtkFileChooserDialog (GTK_FILE_CHOOSER_ACTION_OPEN) |
// Open a file dialog with filters
DEFINE OPENDIALOG oDlg
oDlg:cTitle := "Select Image"
oDlg:cFilter := "Images (*.png;*.jpg)|*.png;*.jpg|All files (*.*)|*.*"
oDlg:cInitialDir := "C:\Pictures"
IF oDlg:Execute()
MsgInfo( "Selected: " + oDlg:cFileName )
ENDIF
TSaveDialog CT_SAVEDIALOG = 41
Standard file save dialog. Prompts the user to choose a filename and location for saving.
| Property | Type | Default | Description |
cFileName | String | "" | Selected/entered file path |
cFilter | String | "All files (*.*)|*.*" | File type filter |
nFilterIndex | Numeric | 1 | Default filter index |
cTitle | String | "Save As" | Dialog title |
cInitialDir | String | "" | Starting directory |
cDefaultExt | String | "" | Default extension (appended if not typed) |
lOverwritePrompt | Logical | .T. | Warn when overwriting existing file |
| Event | Category | Description |
OnClose | Action | Dialog closed |
| Method | Returns | Description |
Execute() | Logical | Shows the dialog. Returns .T. if user confirmed, .F. if cancelled. |
| Platform | Native Dialog |
| Windows | GetSaveFileName() / IFileSaveDialog |
| macOS | NSSavePanel |
| Linux | GtkFileChooserDialog (GTK_FILE_CHOOSER_ACTION_SAVE) |
// Save document with default extension
DEFINE SAVEDIALOG oDlg
oDlg:cTitle := "Save Report"
oDlg:cFilter := "PDF (*.pdf)|*.pdf|HTML (*.html)|*.html"
oDlg:cDefaultExt := "pdf"
IF oDlg:Execute()
SaveReport( oDlg:cFileName )
ENDIF
TFontDialog CT_FONTDIALOG = 42
Standard font selection dialog. Lets the user choose a font face, style, size, and color.
| Property | Type | Default | Description |
cFontName | String | "" | Selected font face name |
nFontSize | Numeric | 10 | Selected font size (points) |
lBold | Logical | .F. | Bold style selected |
lItalic | Logical | .F. | Italic style selected |
lUnderline | Logical | .F. | Underline style selected |
nColor | Color | CLR_BLACK | Selected font color |
| Event | Category | Description |
OnClose | Action | Dialog closed |
| Method | Returns | Description |
Execute() | Logical | Shows the font dialog. Returns .T. if user selected a font. |
| Platform | Native Dialog |
| Windows | ChooseFont() (CHOOSEFONT struct) |
| macOS | NSFontPanel |
| Linux | GtkFontChooserDialog |
TColorDialog CT_COLORDIALOG = 43
Standard color picker dialog. Allows the user to select a color from a palette or define custom colors.
| Property | Type | Default | Description |
nColor | Color | CLR_BLACK | Selected color value |
aCustomColors | Array | {} | Array of custom color values |
| Event | Category | Description |
OnClose | Action | Dialog closed |
| Method | Returns | Description |
Execute() | Logical | Shows the color dialog. Returns .T. if user selected a color. |
| Platform | Native Dialog |
| Windows | ChooseColor() (CHOOSECOLOR struct) |
| macOS | NSColorPanel |
| Linux | GtkColorChooserDialog |
// Pick a background color
DEFINE COLORDIALOG oDlg
IF oDlg:Execute()
oForm:nClrPane := oDlg:nColor
oForm:Refresh()
ENDIF
TFindDialog CT_FINDDIALOG = 44
Modeless find dialog. Provides a text search interface with options for match case and direction.
| Property | Type | Default | Description |
cFindText | String | "" | Text to search for |
lMatchCase | Logical | .F. | Case-sensitive search |
lWholeWord | Logical | .F. | Match whole words only |
lSearchDown | Logical | .T. | Search direction (down = forward) |
| Event | Category | Description |
OnFind | Action | User clicked Find Next |
OnClose | Action | Dialog closed |
| Method | Returns | Description |
Execute() | Logical | Shows the modeless find dialog. |
| Platform | Native Dialog |
| Windows | FindText() (FINDREPLACE struct) |
| macOS | NSTextFinder (find bar) |
| Linux | GtkSearchBar + custom dialog |
TReplaceDialog CT_REPLACEDIALOG = 45
Modeless find-and-replace dialog. Extends TFindDialog with replace functionality.
| Property | Type | Default | Description |
cFindText | String | "" | Text to search for |
cReplaceText | String | "" | Replacement text |
lMatchCase | Logical | .F. | Case-sensitive search |
lWholeWord | Logical | .F. | Match whole words only |
| Event | Category | Description |
OnFind | Action | User clicked Find Next |
OnReplace | Action | User clicked Replace |
OnReplaceAll | Action | User clicked Replace All |
OnClose | Action | Dialog closed |
| Method | Returns | Description |
Execute() | Logical | Shows the modeless replace dialog. |
| Platform | Native Dialog |
| Windows | ReplaceText() (FINDREPLACE struct) |
| macOS | NSTextFinder (find-and-replace bar) |
| Linux | GtkSearchBar + custom replace dialog |
// Find and Replace in a RichEdit
DEFINE REPLACEDIALOG oDlg
oDlg:OnFind := { || FindInEditor( oRichEdit, oDlg:cFindText ) }
oDlg:OnReplace := { || ReplaceInEditor( oRichEdit, oDlg:cFindText, oDlg:cReplaceText ) }
oDlg:OnReplaceAll := { || ReplaceAllInEditor( oRichEdit, oDlg:cFindText, oDlg:cReplaceText ) }
oDlg:Execute()
6 Dialog Controls
All dialog controls are non-visual components. Drop them on a form, configure their properties,
and call Execute() to display the native OS dialog. Each dialog returns .T. when the user
confirms and .F. when cancelled.