# Dlg

Common Operating System Dialogs

Summary

Dlg | Common Operating System Dialogs
Color |
Find / Replace |
Font |
Icon |
Open / Save |
Examples |
About |

### Color

Dlg_Color( | ByRef | Color, |
|  | hGui | = | )

#### Parameters

Color | Initial color and output in RGB format.
hGui | Optional handle to parents Gui. Affects dialog position.

#### Returns

False if user canceled the dialog or if error occurred

### Find / Replace

#### Parameters

hGui | Handle to the parent.
Handler | Notification handler, see below.
Flags | Creation flags, see below.
FindText | Default text to be displayed at the start of the dialog box in find edit box.
ReplaceText | Default text to be displayed at the start of the dialog box in replace edit box.

#### Flags

String containing list of creation flags. You can use “-” prefix to hide that GUI field.

d | down radio button selected in Find dialog.
w | whole word selected.
c | match case selected.

#### Handler

Dialog box is not modal, so it communicates with the script while it is active. Both Find & Replace use the same prototype of notification function.

>     Handler(Event, Flags, FindText, ReplaceText)

Event | C (Close), F (Find), R (Replace), A (replace All)
Flags | String containing flags about user selection; each letter means user has selected that particular GUI element.
FindText | Current find text.
ReplaceText | Current replace text.

#### Returns

Handle of the dialog or 0 if the dialog can’t be created. Returns error code on invalid handler.

### Font

Dlg_Font( | ByRef | Name, |  |
| ByRef | Style, |  |
| ByRef | Color, |  |
|  | Effects | = | true,
|  | hGui | = | 0 | )

#### Parameters

Name | Initial font, output.
Style | Initial style, output.
Color | Initial text color, output.
Effects | Set to false to disable effects (strikeout, underline, color).
hGui | Parent’s handle, affects position.

#### Returns

False if user canceled the dialog or if error occurred.

### Icon

Dlg_Icon( | ByRef | Icon, |
| ByRef | Index, |
|  | hGui | = | )

#### Parameters

Icon | Default icon resource, output.
Index | Default index within resource, output.
hGui | Optional handle of the parent GUI.

#### Returns

False if user canceled the dialog or if error occurred

#### Remarks

This is simple and non-flexible dialog. If you need more features, use <IconEx> instead.

### Open / Save

#### Parameters

hGui | Parent’s handle, positive number by default 0 (influences dialog position).
Title | Dialog title.
Filter | Specify filter as with FileSelectFile. Separate multiple filters with “|”. For instance “All Files (.)|Audio (*.wav; *.mp2; *.mp3)|Documents (*.txt)”
DefaultFilter | Index of default filter (1 based), by default 1.
Root | Specifies startup directory and initial content of “File Name” edit. Directory must have trailing “\”.
DefaultExt | Extension to append when none given .
Flags | White space separated list of flags, by default “FILEMUSTEXIST HIDEREADONLY”.

#### Flags

allowmultiselect | Specifies that the File Name list box allows multiple selections
createprompt | If the user specifies a file that does not exist, this flag causes the dialog box to prompt the user for permission to create the file
dontaddtorecent | Prevents the system from adding a link to the selected file in the file system directory that contains the user’s most recently used documents.
extensiondifferent | Specifies that the user typed a file name extension that differs from the extension specified by defaultExt
filemustexist | Specifies that the user can type only names of existing files in the File Name entry field
forceshowhidden | Forces the showing of system and hidden files, thus overriding the user setting to show or not show hidden files. However, a file that is marked both system and hidden is not shown.
hidereadonly | Hides the Read Only check box.
nochangedir | Restores the current directory to its original value if the user changed the directory while searching for files.
nodereferencelinks | Directs the dialog box to return the path and file name of the selected shortcut (.LNK) file. If this value is not specified, the dialog box returns the path and file name of the file referenced by the shortcut.
novalidate | Specifies that the common dialog boxes allow invalid characters in the returned file name
overwriteprompt | Causes the Save As dialog box to generate a message box if the selected file already exists. The user must confirm whether to overwrite the file.
pathmustexist | Specifies that the user can type only valid paths and file names.
readonly | Causes the Read Only check box to be selected initially when the dialog box is created
showhelp | Causes the dialog box to display the Help button. The hGui receives the HELPMSGSTRING registered messages that the dialog box sends when the user clicks the Help button.
noreadonlyreturn | Specifies that the returned file does not have the Read Only check box selected and is not in a write-protected directory.
notestfilecreate | Specifies that the file is not created before the dialog box is closed. This flag should be specified if the application saves the file on a create-nonmodify network share.

#### Returns

Selected FileName or nothing if cancelled. If more then one file is selected they are separated by new line character.

#### Remarks

Those functions will change the working directory of the script. Use SetWorkingDir afterwards to restore working directory if needed.

### Examples

#### Example1

>       ;basic usage

>       if Dlg_Icon(icon, idx := 4)
>            msgbox Icon:   %icon%`nIndex:  %idx%

>        if Dlg_Color( color := 0xFF00AA )
>           msgbox Color:  %color%

>        if Dlg_Font( font := "Courier New", style := "s16 bold underline italic", color:=0x80)
>             msgbox Font:  %font%`nStyle:  %style%`nColor:  %color%

>        res := Dlg_Open("", "Select several files", "", "", "c:\Windows\", "", "ALLOWMULTISELECT FILEMUSTEXIST HIDEREADONLY")
>        IfNotEqual, res, , MsgBox, %res%
>     return

#### Example2

>         ;create gui and set text color

>         Dlg_Font( font := "Courier New", style := "s16 bold italic", color:=0xFF)

>         Gui Font, %Style% c%Color%, %Font%
>         Gui, Add, Text, ,Hello world.....  :roll:
>         Gui, Show, Autosize
>     return

### About

- Ver 5.02 by majkinetor. See http://www.autohotkey.com/forum/topic17230.html
- Licenced under BSD http://creativecommons.org/licenses/BSD/

Dlg_Color( | ByRef | Color, |
|  | hGui | = | )

Dlg_Font( | ByRef | Name, |  |
| ByRef | Style, |  |
| ByRef | Color, |  |
|  | Effects | = | true,
|  | hGui | = | 0 | )

Dlg_Icon( | ByRef | Icon, |
| ByRef | Index, |
|  | hGui | = | )

Close