AMS Edit

Homepage: Validating Edit Controls

global functions

Set color and backgroundcolor
nRC := DllCall("AHKCtrlSupport\SetAMSEditColor", int, AMSAlphaNumHwnd, int, 0xff0000, int, 0x333333, "Cdecl Int")
nRC 0: error
<>0: ok
AMSAlphaNumHwnd Handle to the control
int RGB-value for the textcolor
int RGB-value for the backgroundcolor



Create a Control
AMSAlphaNumHwnd := DllCall("AHKCtrlSupport\CreateAMSEdit", int, dwexStyle, int, x, int, y, int, width, int, height, int, HWND, int, nID, int, nType, "Cdecl Int")
AMSAlphaNumHwnd Handle to the new control
nStyle i.e. 0x10000000
x, y top left coordinates on the dialog
Width, Height Width and Height of the control
HWND Handle of the dialog
ID Id of the new control
nType Type of the new control
1 = alphanumeric
2 = numeric
3 = date
4 = time



alphanumeric functions

Set maximum length and invalid characters
nRC := DllCall("AHKCtrlSupport\SetAMSEditAlpha", int, AMSAlphaNumHwnd, int, maximalchars, str, invalidchars, "Cdecl Int")
nRC 0: error
<>0: ok
AMSAlphaNumHwnd Handle to the control
int maximalchars i.e. 5 to limit input to 5 characters
str invalidchars do not accept these characters



Get or set new text
nRC := DllCall("AHKCtrlSupport\GetSetAMSEditText", int, AMSAlphaNumHwnd, str, Text, int, nSize, "Cdecl Int")
nRC 0: error
<>0: ok
AMSAlphaNumHwnd Handle to the control
str Text to set or to retrieve
int set to 0 to set the new text
set to size of reserved space to retrieve the current text of the control. Use i.e. VarSetCapacity(xxx,200) to reserve enough space



numeric functions

nRC := DllCall("AHKCtrlSupport\SetAMSEditNumMaxDigits", int, AMSNumHwnd, int, nMaxWholeDigits, int, nMaxDecimalDigits, "Cdecl Int")
nRC 0: error
<>0: ok
AMSNumHwnd Handle to the control
int nMaxWholeDigits i.e. 5 to limit input to 5 characters (before the decimal-point)
int nMaxDecimalDigits i.e. 2 to limit input to 2 characters (after the decimal-point)

nRC := DllCall("AHKCtrlSupport\SetAMSEditNumOptions", int, AMSNumHwnd, int, nAllowNegative, STR, chSeperator, STR, ch1000Seperator, STR, chPrefix, int, nThousandSeperatorevery3digits, "Cdecl Int")
nRC 0: error
<>0: ok
AMSNumHwnd Handle to the control
int nAllowNegative 0 | 1: Allow negative values
str chSeperator Seperator for decimal point
str ch1000Seperator Seperator for points: 1.000.000,22
str chPrefix $1: Char to place before the number
int nThousandSeperatorevery3digits i.e. if set to 2: 23.45.76,543 set to 3: 123.456.789

nRC := DllCall("AHKCtrlSupport\SetAMSEditNumSetMask", int, AMSNumHwnd, STR, szMask, "Cdecl Int")
nRC 0: error
<>0: ok
AMSNumHwnd Handle to the control
STR szMask Enter a mask to use. i.e: #.###.###,## to allow maximum value: 1.234.567,89

Date edit

nRC := DllCall("AHKCtrlSupport\SetAMSEditDate", int, AMSDateHwnd, int, nDay, int, nMonth, int, nYear, "Cdecl Int")
nRC 0: error
<>0: ok
AMSDateHwnd Handle to the control
int nDay nMonth nYear Enter the initial values

Set the date to today
nRC := DllCall("AHKCtrlSupport\SetAMSEditDateToday", int, AMSDateHwnd, "Cdecl Int")
nRC 0: error
<>0: ok
AMSDateHwnd Handle to the control

Set Range
nRC := DllCall("AHKCtrlSupport\SetAMSEditDateRange", int, AMSDateHwnd, int, ndayfrom, int, nmonthfrom, int, nyearfrom, int, ndayto, int, nmonthto, int, nyearto, "Cdecl Int")
nRC 0: error
<>0: ok
AMSDateHwnd Handle to the control
Day, Month, Year (From) smallest date
Day, Month, Year (To) greatest date

Show day before month
nRC := DllCall("AHKCtrlSupport\SetAMSEditDateDayBefMon", int, AMSDateHwnd, int, 0, "Cdecl Int")
nRC 0: error
<>0: ok
AMSDateHwnd Handle to the control
0 | 1 Show day before month

Time edit

nRC := DllCall("AHKCtrlSupport\SetAMSEditTime", int, AMSTimeHwnd, int, nHour, int, nMin, int, nSec, "Cdecl Int")
nRC 0: error
<>0: ok
AMSTimeHwnd Handle to the control
int nHour nMinute nSeconds Enter the initial values

Set the time to NOW
nRC := DllCall("AHKCtrlSupport\SetAMSEditTimeNow", int, AMSTimeHwnd, "Cdecl Int")
nRC 0: error
<>0: ok
AMSTimeHwnd Handle to the control

Set Range
nRC := DllCall("AHKCtrlSupport\SetAMSEditTimeRange", int, AMSTimeHwnd, int, nHourfrom, int, nMinfrom, int, nSecfrom, int, nHourto, int, nMinto, int, nSecto, "Cdecl Int")
nRC 0: error
<>0: ok
AMSTimeHwnd Handle to the control
Hour, Minute, Second (From) smallest time
Hour, Minute, Second (To) greatest time

Set timeformat & show seconds
nRC := DllCall("AHKCtrlSupport\SetAMSEditTime24Sec", int, AMSTimeHwnd, int, 1, int, 1, "Cdecl Int")
nRC 0: error
<>0: ok
AMSTimeHwnd Handle to the control
int nShow24Format Show AM/PM or 24 hours
int nShowSeconds 0 | 1 : Show Seconds

Example:
E X A M P L E: See the script TestCtrlSupportEdit.ahk