import('gui-dialogs') provides Win32 common dialog wrappers for file open/save, folder picking, color selection, and font chooser.
dlg := import('gui-dialogs')
// Open file
result := dlg.openFileDialog({
title: 'Open Image'
filter: 'Images\0*.png;*.jpg\0All Files\0*.*\0'
})
if result.type = :ok -> println('Selected: ' + result.path)
// Save file
result := dlg.saveFileDialog({ title: 'Save As', defaultExt: 'txt' })
// Pick a color
result := dlg.chooseColor({ initialColor: [255, 0, 0] })
if result.type = :ok -> println(result.color)
// Pick a folder
result := dlg.pickFolder({ title: 'Choose output folder' })
// Choose a font
result := dlg.chooseFont({})
if result.type = :ok -> println(result.name + ' ' + string(result.size))
Displays a file open dialog. Returns {type: :ok, path} or {type: :cancel}.
Options:
title— dialog titlefilter— file type filter string (null-separated pairs)initialDir— starting directory
Displays a file save dialog. Returns {type: :ok, path} or {type: :cancel}.
Options:
title— dialog titlefilter— file type filter stringdefaultExt— default file extensioninitialDir— starting directory
Displays a color chooser dialog. Returns {type: :ok, color} or {type: :cancel}.
Options:
initialColor—[r, g, b]starting colorfullOpen— show custom color controls immediately
Displays a folder picker dialog. Returns {type: :ok, path} or {type: :cancel}.
Options:
title— dialog title
Displays a font chooser dialog. Returns {type: :ok, name, size, weight, italic, color} or {type: :cancel}.
| Constant | Value |
|---|---|
OFN_PATHMUSTEXIST |
2048 |
OFN_FILEMUSTEXIST |
4096 |
OFN_OVERWRITEPROMPT |
2 |
OFN_EXPLORER |
524288 |
| Constant | Value |
|---|---|
CC_RGBINIT |
1 |
CC_FULLOPEN |
2 |
| Constant | Value |
|---|---|
CF_SCREENFONTS |
1 |
CF_EFFECTS |
256 |
CF_INITTOLOGFONTSTRUCT |
64 |