https://git.reactos.org/?p=reactos.git;a=commitdiff;h=debb1e521a2feb5d98e51…
commit debb1e521a2feb5d98e51dfbdc0bd0b3082c59bd
Author: Eric Kohl <eric.kohl(a)reactos.org>
AuthorDate: Sun Oct 14 21:02:45 2018 +0200
Commit: Eric Kohl <eric.kohl(a)reactos.org>
CommitDate: Sun Oct 14 21:02:45 2018 +0200
[NETCFGX] Implement the Min and Max options for int, long and word parameters.
CORE-15095
---
dll/win32/netcfgx/propertypage.c | 85 ++++++++++++++++++++++++++++++++++++++--
1 file changed, 82 insertions(+), 3 deletions(-)
diff --git a/dll/win32/netcfgx/propertypage.c b/dll/win32/netcfgx/propertypage.c
index b069cf6062..abf44daa0d 100644
--- a/dll/win32/netcfgx/propertypage.c
+++ b/dll/win32/netcfgx/propertypage.c
@@ -43,6 +43,8 @@ typedef struct _PARAMETER
INT iBase;
INT iStep;
+ LONG lMin;
+ LONG lMax;
} PARAMETER, *PPARAMETER;
typedef struct _PARAMETER_ARRAY
@@ -199,6 +201,41 @@ GetIntValue(
}
+static DWORD
+GetLongValue(
+ _In_ HKEY hKey,
+ _In_ PWSTR pValueName,
+ _In_ LONG lDefault,
+ _Out_ PLONG pValue)
+{
+ WCHAR szBuffer[24];
+ DWORD dwLength = 0;
+ DWORD dwRegType;
+ PWSTR ptr = NULL;
+
+ dwLength = sizeof(szBuffer);
+ RegQueryValueExW(hKey,
+ pValueName,
+ NULL,
+ &dwRegType,
+ (LPBYTE)szBuffer,
+ &dwLength);
+
+ if (dwRegType == REG_SZ && dwLength >= sizeof(WCHAR))
+ {
+ *pValue = wcstol(szBuffer, &ptr, 10);
+ if (*pValue == 0 && ptr != NULL)
+ *pValue = lDefault;
+ }
+ else
+ {
+ *pValue = lDefault;
+ }
+
+ return ERROR_SUCCESS;
+}
+
+
static
DWORD
GetEnumOptions(
@@ -350,6 +387,7 @@ BuildParameterArray(
DWORD dwSubKeys, dwMaxSubKeyLen, dwKeyLen, dwIndex;
PWSTR pszType = NULL;
LONG lError;
+ LONG lDefaultMin, lDefaultMax;
BOOL ret = FALSE;
hDriverKey = SetupDiOpenDevRegKey(DeviceInfoSet,
@@ -493,7 +531,38 @@ BuildParameterArray(
ParamArray->Array[dwIndex].Type == WORD_TYPE ||
ParamArray->Array[dwIndex].Type == DWORD_TYPE)
{
- /* FIXME: Read Min and Max values */
+ if (ParamArray->Array[dwIndex].Type == INT_TYPE)
+ {
+ lDefaultMin = -32768L; //MIN_SHORT;
+ lDefaultMax = 32767L; //MAX_SHORT;
+ }
+ else if (ParamArray->Array[dwIndex].Type == LONG_TYPE)
+ {
+ lDefaultMin = (-2147483647L - 1); // MIN_LONG;
+ lDefaultMax = 2147483647L; // MAX_LONG;
+ }
+ else if (ParamArray->Array[dwIndex].Type == WORD_TYPE)
+ {
+ lDefaultMin = 0L;
+ lDefaultMax = 65535L; // MAX_WORD;
+ }
+#if 0
+ else if (ParamArray->Array[dwIndex].Type == DWORD_TYPE)
+ {
+ lDefaultMin = 0;
+ lDefaultMax = 4294967295; //MAX_DWORD;
+ }
+#endif
+
+ GetLongValue(hParamKey,
+ L"Min",
+ lDefaultMin,
+ &ParamArray->Array[dwIndex].lMin);
+
+ GetLongValue(hParamKey,
+ L"Max",
+ lDefaultMax,
+ &ParamArray->Array[dwIndex].lMax);
GetIntValue(hParamKey,
L"Base",
@@ -692,14 +761,24 @@ DisplayParameter(
ShowWindow(GetDlgItem(hwnd, IDC_PROPERTY_VALUE_LIST), SW_HIDE);
hwndControl = GetDlgItem(hwnd, IDC_PROPERTY_VALUE_UPDN);
- EnableWindow(hwndControl, Parameter->bPresent);
- ShowWindow(hwndControl, SW_SHOW);
+
+ if (Parameter->Type != DWORD_TYPE)
+ {
+ EnableWindow(hwndControl, Parameter->bPresent);
+ ShowWindow(hwndControl, SW_SHOW);
+ }
if (Parameter->Type == WORD_TYPE || Parameter->Type == DWORD_TYPE)
SendMessage(hwndControl, UDM_SETBASE, Parameter->iBase, 0);
else
SendMessage(hwndControl, UDM_SETBASE, 10, 0);
+ if (Parameter->Type != DWORD_TYPE)
+ {
+ TRACE("SetMin %ld SetMax %ld\n", Parameter->lMin,
Parameter->lMax);
+ SendMessage(hwndControl, UDM_SETRANGE32, Parameter->lMin,
Parameter->lMax);
+ }
+
hwndControl = GetDlgItem(hwnd, IDC_PROPERTY_VALUE_EDIT);
EnableWindow(hwndControl, Parameter->bPresent);
ShowWindow(hwndControl, SW_SHOW);