| MaskEditHwnd | Handle to the new control |
| Style | See AHK documentation for edit control styles |
| Edit1HWnd | Handle to an existing edit control. This one gets replaced by the mask edit control |
| fRC | Error: 0 ok: 1 |
| MaskEditHwnd | Handle to the mask edit control. |
| MaskEdit | Mask for the control. . (period) Decimal placeholder. The actual character used is the one specified as the decimal placeholder in your international settings. This character is treated as a literal for masking purposes. , (comma) Thousands separator. The actual character used is the one specified as the thousands separator in your international settings. This character is treated as a literal for masking purposes. : (colon) Time separator. The actual character used is the one specified as the time separator in your international settings. This character is treated as a literal for masking purposes. / (slash) Date separator. The actual character used is the one specified as the date separator in your international settings. This character is treated as a literal for masking purposes. # Digit placeholder. (0-9) A Alphanumeric character placeholder (0-9 and a-Z) ? Alphabetic placeholder (a-Z) > Alphabetic placeholder, but forces uppercase chars (A-Z) < Alphabetic placeholder, but forces them to lowercase (a-z) & Character placeholder. Valid values for this placeholder are ANSI characters in the following ranges: 32-126 and 128-255. \ Literal escape. Use this to place your own literals in the mask - note that two backslashes must be used in string literals to accomodate for the fact that this is also treated as an escape character for ASNI/ISO string formatting. As an example, lets look at a string to mask an IP address: "IP \\Address: ###\\.###\\.###\\.###" |
| fRC | Error: 0 ok: 1 |
| MaskEditHwnd | Handle to mask edit control. |
| MaskEdit | Retrieves the current mask of the control |
| int 20 | Length of the string. Use i.e. VarSetCapacity(xxx,200) to reserve enough space |
| fRC | Error: 0 ok: 1 |
| MaskEditHwnd | Handle to mask edit control. |
| MaskEdit | The character you want set as placeholder / The character that is currently used as placeholder |
| fRC | Error: 0 ok: 1 |
| MaskEditHwnd | Handle to mask edit control. |
| MaskEdit | The fully formated mask with all input data. |
| int xxx | Length of the string. Use i.e. VarSetCapacity(xxx,200) to reserve enough space |
| fRC | Error: 0 ok: 1 |
| MaskEditHwnd | Handle to mask edit control. |
| MaskEdit | The fully formated mask with all input data. |
| int xxx | Length of the string. Use i.e. VarSetCapacity(xxx,200) to reserve enough space |
| fRC | Error: 0 ok: 1 |
| MaskEditHwnd | Handle to mask edit control. |
| MaskEdit | Each character is entered into the control as if the user typed it in. |
| int xxx | Begin position for inserting or overwriting the Insert symbols in the mask. |
| bool bAllowPrompt | whether or not the prompt symbol is a valid input character. |
| nRC | Error: 0 ok: 1 |
| MaskEditHwnd | Handle to mask edit control. |
| szValidChars | Enter the valid characters. Syntax: |00: - 99: This parameter selects the position of a letter of the input string. | is a spererator for readibility. 00 is the first character. You can set the valid characters for 99 letters. The two letters must be followed by a colon : Specify the valid characters one by one, i.e. abcdef012345ABCDKLMN or specify the range, i.e. a-f0-5A-DK-N Example: 00:a-z|01:0-9|02:ABCDEFabcdef|03:a-fh-z|07:24680 1.letter: all lower case letters from a-z are valid 2.letter: you can only enter digits from 0 to 9 3.letter: you can enter the letters a-z WITHOUT the letter g 4.-6. letter: everything is valid (You can combine the valid letters with the mask.) 7.letter: only even digits are valid |
| nRC | Error: 0 ok: 1 |
| MaskEditHwnd | Handle to mask edit control. |
| szValidChars | Syntax like SetEditMaskValidChars. You can call this function as many times as needed. To delete the whole data, call this function with an empty string. i.e:szValidChars=00:a-f|01:g-l|02:m-p|08:AB|09:CD|10:EF -> call the function szValidChars=00:a|01:pj|02:u|04:0-5|05:0-5|06:0-5|08:X|09:Y|10:Z -> call the function again with that values szValidChars=00:r-z|04:3-6|05:3-6|06:3-6|08:I-P|09:I-P|10:I-P -> and once again You can for example enter these values: (*=any char that is valid for the mask) bho***ADF alp***BDF ap*432XYZ s**456IPM ... |
Gui, Add, Text, x170 y160 w100 h20, Enter abc-123-ABC
Gui, Add, Edit, x170 y180 w100 h20, Edit1
Gui, Add, Button, x170 y210 w100 h20 gRetrieveText, Retrieve Text
Gui, Show, w550 h550, this is a unique title
WinGet, HWND, ID, this is a unique title
Edit1HWnd := GetChildHWND(HWND, "Edit1") ;Get HWND of an existing Edit
...
...
; --------------- Create a Masked Edit ----------------------------------
; -----------------------------------------------------------------------
x = 80
y = 15
width = 250
height = 20
nID = 100
dwexStyle := 0x10000000
MaskEditHwnd := DllCall("AHKCtrlSupport\CreateMaskEdit", int, dwexStyle, int, x, int, y, int, width, int, height, int, HWND, int, nID, "Cdecl Int")
if (errorlevel <> 0) || (MaskEditHwnd = 0)
{
MsgBox error while calling CreateMaskEdit Errorlevel: %errorlevel% - RC: %MaskEditHwnd%
return
}
MaskEdit=<<<-###->>>
nRC := DllCall("AHKCtrlSupport\SetMaskEditMask", int, MaskEditHwnd, str, MaskEdit, "Cdecl Int")
if (errorlevel <> 0) || (nRC = 0)
{
MsgBox error while calling SetMaskEditMask Errorlevel: %errorlevel% - RC: %nRC%
return
}
VarSetCapacity(MaskEdit, 20)
MaskEdit=NONE
nRC := DllCall("AHKCtrlSupport\GetMaskEditMask", int, MaskEditHwnd, str, MaskEdit, int, 20, "Cdecl Int")
if (errorlevel <> 0) || (nRC = 0)
{
MsgBox error while calling GetMaskEditMask Errorlevel: %errorlevel% - RC: %nRC%
return
}
;ToolTip, %MaskEdit%
MaskEditPromptSymbol=@
nRC := DllCall("AHKCtrlSupport\SetEditMaskPromptSymbol", int, MaskEditHwnd, str, MaskEditPromptSymbol, "Cdecl Int")
if (errorlevel <> 0) || (nRC = 0)
{
MsgBox error while calling SetEditMaskPromptSymbol Errorlevel: %errorlevel% - RC: %nRC%
return
}
szValidChars=00:abcdef|01:ghikl|02:mnop|08:AB|09:CD|10:EF
nRC := DllCall("AHKCtrlSupport\SetEditMaskValidChars", int, MaskEditHwnd, str, szValidChars, "Cdecl Int")
if (errorlevel <> 0) || (nRC = 0)
{
MsgBox error while calling SetEditMaskValidChars Errorlevel: %errorlevel% - RC: %nRC%
return
}
szValidChars=00:ac|01:gh|02:mn
nRC := DllCall("AHKCtrlSupport\SetEditMaskValidCharSet", int, MaskEditHwnd, str, szValidChars, "Cdecl Int")
szValidChars=00:de|01:ij|02:op
nRC := DllCall("AHKCtrlSupport\SetEditMaskValidCharSet", int, MaskEditHwnd, str, szValidChars, "Cdecl Int")
szValidChars=00:f|01:g-l|02:mo
nRC := DllCall("AHKCtrlSupport\SetEditMaskValidCharSet", int, MaskEditHwnd, str, szValidChars, "Cdecl Int")
; --------------- Create another Masked Edit ----------------------------------
; -----------------------------------------------------------------------
x = 80
y = 145
width = 250
height = 20
nID = 100
dwexStyle := 0x10000000
MaskEditHwnd2 := DllCall("AHKCtrlSupport\CreateMaskEdit", int, dwexStyle, int, x, int, y, int, width, int, height, int, HWND, int, nID, "Cdecl Int")
if (errorlevel <> 0) || (MaskEditHwnd = 0)
{
MsgBox error while calling CreateMaskEdit Errorlevel: %errorlevel% - RC: %MaskEditHwnd%
return
}
MaskEdit=<<<-###->>>
nRC := DllCall("AHKCtrlSupport\SetMaskEditMask", int, MaskEditHwnd2, str, MaskEdit, "Cdecl Int")
if (errorlevel <> 0) || (nRC = 0)
{
MsgBox error while calling SetMaskEditMask Errorlevel: %errorlevel% - RC: %nRC%
return
}
VarSetCapacity(MaskEdit, 20)
MaskEdit=NONE
nRC := DllCall("AHKCtrlSupport\GetMaskEditMask", int, MaskEditHwnd2, str, MaskEdit, int, 20, "Cdecl Int")
if (errorlevel <> 0) || (nRC = 0)
{
MsgBox error while calling GetMaskEditMask Errorlevel: %errorlevel% - RC: %nRC%
return
}
;ToolTip, %MaskEdit%
MaskEditPromptSymbol=*
nRC := DllCall("AHKCtrlSupport\SetEditMaskPromptSymbol", int, MaskEditHwnd2, str, MaskEditPromptSymbol, "Cdecl Int")
if (errorlevel <> 0) || (nRC = 0)
{
MsgBox error while calling SetEditMaskPromptSymbol Errorlevel: %errorlevel% - RC: %nRC%
return
}
szValidChars=00:a-f|01:g-l|02:m-p|08:AB|09:CD|10:EF
nRC := DllCall("AHKCtrlSupport\SetEditMaskValidCharSet", int, MaskEditHwnd2, str, szValidChars, "Cdecl Int")
szValidChars=00:a|01:pj|02:u|04:0-5|05:0-5|06:0-5|08:X|09:Y|10:Z
nRC := DllCall("AHKCtrlSupport\SetEditMaskValidCharSet", int, MaskEditHwnd2, str, szValidChars, "Cdecl Int")
szValidChars=00:r-z|04:3-6|05:3-6|06:3-6|08:I-P|09:I-P|10:I-P
nRC := DllCall("AHKCtrlSupport\SetEditMaskValidCharSet", int, MaskEditHwnd2, str, szValidChars, "Cdecl Int")
...
...
RetrieveText:
{
VarSetCapacity(EnteredData, 20)
fRC := DllCall("AHKCtrlSupport\GetEditMaskInputData", DWORD, MaskEditHwnd, str, EnteredData, int, 20, "Cdecl Int")
if (errorlevel <> 0) || (fRC = 0)
{
MsgBox error while calling GetEditMaskInputData Errorlevel: %errorlevel% - RC: %TransBtnHwnd%
return
}
MsgBox %EnteredData%
}
return