[SYSDM]
authorEric Kohl <eric.kohl@reactos.org>
Tue, 1 Nov 2011 17:47:18 +0000 (17:47 +0000)
committerEric Kohl <eric.kohl@reactos.org>
Tue, 1 Nov 2011 17:47:18 +0000 (17:47 +0000)
Handle the user wait interval.

svn path=/trunk/; revision=54281

reactos/dll/cpl/sysdm/hardprof.c

index 0d48517..817b6dd 100644 (file)
@@ -35,6 +35,109 @@ RenameProfDlgProc(HWND hwndDlg,
 }
 
 
 }
 
 
+static
+DWORD
+GetUserWaitInterval(VOID)
+{
+    DWORD dwWaitInterval = 30;
+    DWORD dwSize;
+    HKEY hKey;
+
+    if (RegOpenKeyExW(HKEY_LOCAL_MACHINE,
+                      L"System\\CurrentControlSet\\Control\\IDConfigDB",
+                      0,
+                      KEY_QUERY_VALUE,
+                      &hKey))
+        return dwWaitInterval;
+
+    dwSize = sizeof(DWORD);
+    RegQueryValueExW(hKey,
+                     L"UserWaitInterval",
+                     NULL,
+                     NULL,
+                     (LPBYTE)&dwWaitInterval,
+                     &dwSize);
+
+    RegCloseKey(hKey);
+
+    return dwWaitInterval;
+}
+
+
+static
+VOID
+SetUserWaitInterval(DWORD dwWaitInterval)
+{
+    HKEY hKey;
+
+    if (RegOpenKeyExW(HKEY_LOCAL_MACHINE,
+                      L"System\\CurrentControlSet\\Control\\IDConfigDB",
+                      0,
+                      KEY_SET_VALUE,
+                      &hKey))
+        return;
+
+    RegSetValueExW(hKey,
+                   L"UserWaitInterval",
+                   0,
+                   REG_DWORD,
+                   (LPBYTE)&dwWaitInterval,
+                   sizeof(DWORD));
+
+    RegCloseKey(hKey);
+}
+
+
+static
+VOID
+OnInitDialog(HWND hwndDlg)
+{
+    DWORD dwWaitInterval;
+
+    SendMessage(GetDlgItem(hwndDlg, IDC_HRDPROFUP),
+                BM_SETIMAGE,(WPARAM)IMAGE_ICON,
+                (LPARAM)(HANDLE)LoadIcon(hApplet, MAKEINTRESOURCE(IDI_UP)));
+    SendMessage(GetDlgItem(hwndDlg, IDC_HRDPROFDWN),
+                BM_SETIMAGE,(WPARAM)IMAGE_ICON,
+                (LPARAM)(HANDLE)LoadIcon(hApplet, MAKEINTRESOURCE(IDI_DOWN)));
+
+
+    SendDlgItemMessageW(hwndDlg, IDC_HRDPROFUPDWN, UDM_SETRANGE, (WPARAM)0, (LPARAM)MAKELONG((SHORT)500, 0));
+
+    dwWaitInterval = GetUserWaitInterval();
+    if (dwWaitInterval == (DWORD)-1)
+    {
+        CheckDlgButton(hwndDlg, IDC_HRDPROFWAIT, BST_CHECKED);
+        SendDlgItemMessageW(hwndDlg, IDC_HRDPROFUPDWN, UDM_SETPOS, 0, 30);
+        EnableWindow(GetDlgItem(hwndDlg, IDC_HRDPROFEDIT), FALSE);
+    }
+    else
+    {
+        CheckDlgButton(hwndDlg, IDC_HRDPROFSELECT, BST_CHECKED);
+        SendDlgItemMessageW(hwndDlg, IDC_HRDPROFUPDWN, UDM_SETPOS, 0, dwWaitInterval);
+    }
+}
+
+
+static
+VOID
+OnOk(HWND hwndDlg)
+{
+    DWORD dwWaitInterval;
+
+    if (IsDlgButtonChecked(hwndDlg, IDC_HRDPROFWAIT) == BST_CHECKED)
+    {
+        dwWaitInterval = (DWORD)-1;
+    }
+    else
+    {
+        dwWaitInterval = LOWORD(SendDlgItemMessageW(hwndDlg, IDC_HRDPROFUPDWN, UDM_GETPOS, 0, 0));
+    }
+
+    SetUserWaitInterval(dwWaitInterval);
+}
+
+
 /* Property page dialog callback */
 INT_PTR CALLBACK
 HardProfDlgProc(HWND hwndDlg,
 /* Property page dialog callback */
 INT_PTR CALLBACK
 HardProfDlgProc(HWND hwndDlg,
@@ -49,18 +152,8 @@ HardProfDlgProc(HWND hwndDlg,
     switch (uMsg)
     {
         case WM_INITDIALOG:
     switch (uMsg)
     {
         case WM_INITDIALOG:
-        {
-            SendMessage(GetDlgItem(hwndDlg, IDC_HRDPROFUP),
-                        BM_SETIMAGE,(WPARAM)IMAGE_ICON,
-                        (LPARAM)(HANDLE)LoadIcon(hApplet, MAKEINTRESOURCE(IDI_UP)));
-            SendMessage(GetDlgItem(hwndDlg, IDC_HRDPROFDWN),
-                        BM_SETIMAGE,(WPARAM)IMAGE_ICON,
-                        (LPARAM)(HANDLE)LoadIcon(hApplet, MAKEINTRESOURCE(IDI_DOWN)));
-
-            SendDlgItemMessageW(hwndDlg, IDC_HRDPROFUPDWN, UDM_SETRANGE, (WPARAM) 0, (LPARAM) MAKELONG((short) 500, 0));
-            //SendDlgItemMessageW(hwndDlg, IDC_HRDPROFUPDWN, UDM_SETPOS, (WPARAM) 0, (LPARAM) MAKELONG((short) 30, 0));
-        }
-        break;
+            OnInitDialog(hwndDlg);
+            break;
 
         case WM_COMMAND:
             switch (LOWORD(wParam))
 
         case WM_COMMAND:
             switch (LOWORD(wParam))
@@ -72,7 +165,17 @@ HardProfDlgProc(HWND hwndDlg,
                               (DLGPROC)RenameProfDlgProc);
                     break;
 
                               (DLGPROC)RenameProfDlgProc);
                     break;
 
+                case IDC_HRDPROFWAIT:
+                    EnableWindow(GetDlgItem(hwndDlg, IDC_HRDPROFEDIT), FALSE);
+                    return TRUE;
+
+                case IDC_HRDPROFSELECT:
+                    EnableWindow(GetDlgItem(hwndDlg, IDC_HRDPROFEDIT), TRUE);
+                    return TRUE;
+
                 case IDOK:
                 case IDOK:
+                    OnOk(hwndDlg);
+
                 case IDCANCEL:
                     EndDialog(hwndDlg,
                               LOWORD(wParam));
                 case IDCANCEL:
                     EndDialog(hwndDlg,
                               LOWORD(wParam));