CmnDlg

Common Operating System dialogs

Summary
Common Operating System dialogs
Display standard color dialog
Display standard Find and Replace dialog boxes.
Display standard font dialog
Display standard icon dialog.
Display standard Open / Save dialog

Color

CmnDlg_Color(ByRef pColor,  
 hGui = )

Display standard color dialog

Parameters

pColorInitial color and output in RGB format,
hGuiOptional handle to parents HWND

Returns

False if user canceled the dialog or if error occurred

Find / Replace

Display standard Find and Replace dialog boxes.

Parameters

hGuiHandle to parents HWND
lblLabel used for communication with dialog.  CmnDlg_Event, CmnDlg_FindWhat and CmnDlg_Flags hold the dialog data
flagsCreation flags, see below.
deffDefault text to be displayed at the start of the dialog box in find edit box
defrDefault 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

Globals

Dialog box is not modal, so it communicates with the script using 4 global variables:

Event”close”, “find”, “replace”, “replace_all”
Flagsstring contaning flags about user selection; each letter means user has selected that particular GUI element.
FindWhatuser find text
ReplaceWithuser replace text

Returns

Handle of the dialog or 0 if dialog can’t be created.  Can also return “Invalid Label” if lbl is not valid.

Font

CmnDlg_Font(ByRef pFace,  
ByRef pStyle,  
ByRef pColor,  
 pEffects = true,
 hGui = 0)

Display standard font dialog

Parameters

pFaceInitial font, output
pStyleInitial style, output
pColorInitial text color, output
pEffectsSet 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

CmnDlg_Icon(ByRef sIcon,  
ByRef idx,  
 hGui = )

Display standard icon dialog.

Parameters

sIconDefault icon resource, output
idxDefault 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-fleixibile dialog.  If you need more flexibility, use <IconEx> instead.

Open / Save

Display standard Open / Save dialog

Parameters

hGuiParent’s handle, positive number by default 0 (influences dialog position)
TitleDialog title
FilterSpecify filter as with FileSelectFile.  Seperate multiple filters with “|”
DefultFilterIndex of default filter, by default 1
RootSpecifies startup directory and initial content of “File Name” edit.  Directory must have trailing “\”.
DefaulltExtExtension 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 defaulltExt
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 Emtpy when cancelled.  If more then one file is selected they are separated by new line character.

Examples

Example1

  ;basic usage

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

if CmnDlg_Color( color := 0xFF00AA )
msgbox Color: %color%

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

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

Example2

   ;create gui and set text color

CmnDlg_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

CmnDlg_Color(ByRef pColor,  
 hGui = )
Display standard color dialog
CmnDlg_Font(ByRef pFace,  
ByRef pStyle,  
ByRef pColor,  
 pEffects = true,
 hGui = 0)
Display standard font dialog
CmnDlg_Icon(ByRef sIcon,  
ByRef idx,  
 hGui = )
Display standard icon dialog.