Dlg

Common Operating System Dialogs

Summary

Color

Dlg_Color(ByRef Color,  
 hGui = )

(See Dlg_color.png)

Parameters

ColorInitial color and output in RGB format.
hGuiOptional handle to parents Gui.  Affects dialog position.

Returns

False if user canceled the dialog or if error occurred

Find / Replace

(See Dlg_find.png)

(See Dlg_replace.png)

Parameters

hGuiHandle to the parent.
HandlerNotification handler, see below.
FlagsCreation flags, see below.
FindTextDefault text to be displayed at the start of the dialog box in find edit box.
ReplaceTextDefault 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.

ddown radio button selected in Find dialog.
wwhole word selected.
cmatch 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)
EventC (Close), F (Find), R (Replace), A (replace All)
FlagsString containing flags about user selection; each letter means user has selected that particular GUI element.
FindTextCurrent find text.
ReplaceTextCurrent 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)

(See Dlg_font.png)

Parameters

NameInitial font, output.
StyleInitial style, output.
ColorInitial text color, output.
EffectsSet to false to disable effects (strikeout, underline, color).
hGuiParent’s handle, affects position.

Returns

False if user canceled the dialog or if error occurred.

Icon

Dlg_Icon(ByRef Icon,  
ByRef Index,  
 hGui = )

(See Dlg_icon.png)

Parameters

IconDefault icon resource, output.
IndexDefault index within resource, output.
hGuiOptional 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

(See Dlg_open.png)

Parameters

hGuiParent’s handle, positive number by default 0 (influences dialog position).
TitleDialog title.
FilterSpecify filter as with FileSelectFile.  Separate multiple filters with “|”.  For instance “All Files (.)|Audio (*.wav; *.mp2; *.mp3)|Documents (*.txt)”
DefaultFilterIndex of default filter (1 based), by default 1.
RootSpecifies startup directory and initial content of “File Name” edit.  Directory must have trailing “\”.
DefaultExtExtension to append when none given .
FlagsWhite space separated list of flags, by default “FILEMUSTEXIST HIDEREADONLY”.

Flags

allowmultiselectSpecifies that the File Name list box allows multiple selections
createpromptIf 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
dontaddtorecentPrevents the system from adding a link to the selected file in the file system directory that contains the user’s most recently used documents.
extensiondifferentSpecifies that the user typed a file name extension that differs from the extension specified by defaultExt
filemustexistSpecifies that the user can type only names of existing files in the File Name entry field
forceshowhiddenForces 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.
hidereadonlyHides the Read Only check box.
nochangedirRestores the current directory to its original value if the user changed the directory while searching for files.
nodereferencelinksDirects 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.
novalidateSpecifies that the common dialog boxes allow invalid characters in the returned file name
overwritepromptCauses 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.
pathmustexistSpecifies that the user can type only valid paths and file names.
readonlyCauses the Read Only check box to be selected initially when the dialog box is created
showhelpCauses 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.
noreadonlyreturnSpecifies that the returned file does not have the Read Only check box selected and is not in a write-protected directory.
notestfilecreateSpecifies 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
Dlg_Color(ByRef Color,  
 hGui = )
Dlg_Font(ByRef Name,  
ByRef Style,  
ByRef Color,  
 Effects = true,
 hGui = 0)
Dlg_Icon(ByRef Icon,  
ByRef Index,  
 hGui = )
Advanced icon dialog
Close