[MSGINA]
authorEric Kohl <eric.kohl@reactos.org>
Sun, 19 Jan 2014 01:33:19 +0000 (01:33 +0000)
committerEric Kohl <eric.kohl@reactos.org>
Sun, 19 Jan 2014 01:33:19 +0000 (01:33 +0000)
- Display the lock message on the lock and unlock dialogs.
- Implement the DontDisplayLastUserName and ShutdownWithoutLogon options.
- Read the DefaultUserName and DefaultDomain and display the user name on the logon dialog unless the DontDisplayLastUserName option is enabled.

svn path=/trunk/; revision=61681

reactos/dll/win32/msgina/gui.c
reactos/dll/win32/msgina/msgina.c
reactos/dll/win32/msgina/msgina.h

index 83b1ebd..8f8d17a 100644 (file)
@@ -478,14 +478,20 @@ LoggedOutWindowProc(
     {
         case WM_INITDIALOG:
         {
     {
         case WM_INITDIALOG:
         {
-            /* FIXME: take care of DontDisplayLastUserName, NoDomainUI, ShutdownWithoutLogon */
+            /* FIXME: take care of NoDomainUI */
             pgContext = (PGINA_CONTEXT)lParam;
             SetWindowLongPtr(hwndDlg, GWL_USERDATA, (DWORD_PTR)pgContext);
 
             pgContext = (PGINA_CONTEXT)lParam;
             SetWindowLongPtr(hwndDlg, GWL_USERDATA, (DWORD_PTR)pgContext);
 
+            if (pgContext->bDontDisplayLastUserName == FALSE)
+                SetDlgItemTextW(hwndDlg, IDC_USERNAME, pgContext->UserName);
+
             if (pgContext->bDisableCAD == TRUE)
                 EnableWindow(GetDlgItem(hwndDlg, IDCANCEL), FALSE);
 
             if (pgContext->bDisableCAD == TRUE)
                 EnableWindow(GetDlgItem(hwndDlg, IDCANCEL), FALSE);
 
-            SetFocus(GetDlgItem(hwndDlg, IDC_USERNAME));
+            if (pgContext->bShutdownWithoutLogon == FALSE)
+                EnableWindow(GetDlgItem(hwndDlg, IDC_SHUTDOWN), FALSE);
+
+            SetFocus(GetDlgItem(hwndDlg, pgContext->bDontDisplayLastUserName ? IDC_USERNAME : IDC_PASSWORD));
 
             pgContext->hBitmap = LoadImage(hDllInstance, MAKEINTRESOURCE(IDI_ROSLOGO), IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR);
             return TRUE;
 
             pgContext->hBitmap = LoadImage(hDllInstance, MAKEINTRESOURCE(IDI_ROSLOGO), IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR);
             return TRUE;
@@ -573,6 +579,24 @@ GUILoggedOutSAS(
 }
 
 
 }
 
 
+static VOID
+SetLockMessage(HWND hwnd,
+               INT nDlgItem,
+               PGINA_CONTEXT pgContext)
+{
+    WCHAR Buffer1[256];
+    WCHAR Buffer2[256];
+    WCHAR Buffer3[512];
+
+    LoadStringW(pgContext->hDllInstance, IDS_LOCKMSG, Buffer1, 256);
+
+    wsprintfW(Buffer2, L"%s\\%s", pgContext->Domain, pgContext->UserName);
+    wsprintfW(Buffer3, Buffer1, Buffer2);
+
+    SetDlgItemTextW(hwnd, nDlgItem, Buffer3);
+}
+
+
 static
 INT_PTR
 CALLBACK
 static
 INT_PTR
 CALLBACK
@@ -592,11 +616,14 @@ UnlockWindowProc(
             pgContext = (PGINA_CONTEXT)lParam;
             SetWindowLongPtr(hwndDlg, GWL_USERDATA, (DWORD_PTR)pgContext);
 
             pgContext = (PGINA_CONTEXT)lParam;
             SetWindowLongPtr(hwndDlg, GWL_USERDATA, (DWORD_PTR)pgContext);
 
+            SetLockMessage(hwndDlg, IDC_LOCKMSG, pgContext);
+
+            SetDlgItemTextW(hwndDlg, IDC_USERNAME, pgContext->UserName);
+            SetFocus(GetDlgItem(hwndDlg, IDC_PASSWORD));
+
             if (pgContext->bDisableCAD == TRUE)
                 EnableWindow(GetDlgItem(hwndDlg, IDCANCEL), FALSE);
 
             if (pgContext->bDisableCAD == TRUE)
                 EnableWindow(GetDlgItem(hwndDlg, IDCANCEL), FALSE);
 
-            SetFocus(GetDlgItem(hwndDlg, IDC_USERNAME));
-
             pgContext->hBitmap = LoadImage(hDllInstance, MAKEINTRESOURCE(IDI_ROSLOGO), IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR);
             return TRUE;
 
             pgContext->hBitmap = LoadImage(hDllInstance, MAKEINTRESOURCE(IDI_ROSLOGO), IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR);
             return TRUE;
 
@@ -678,23 +705,6 @@ GUILockedSAS(
 }
 
 
 }
 
 
-static VOID
-OnInitLockedDlg(HWND hwnd,
-                PGINA_CONTEXT pgContext)
-{
-    WCHAR Buffer1[256];
-    WCHAR Buffer2[256];
-    WCHAR Buffer3[512];
-
-    LoadStringW(pgContext->hDllInstance, IDS_LOCKMSG, Buffer1, 256);
-
-    wsprintfW(Buffer2, L"%s\\%s", pgContext->Domain, pgContext->UserName);
-    wsprintfW(Buffer3, Buffer1, Buffer2);
-
-    SetDlgItemTextW(hwnd, IDC_LOCKMSG, Buffer3);
-}
-
-
 static INT_PTR CALLBACK
 LockedWindowProc(
     IN HWND hwndDlg,
 static INT_PTR CALLBACK
 LockedWindowProc(
     IN HWND hwndDlg,
@@ -714,7 +724,7 @@ LockedWindowProc(
             SetWindowLongPtr(hwndDlg, GWL_USERDATA, (DWORD_PTR)pgContext);
 
             pgContext->hBitmap = LoadImage(hDllInstance, MAKEINTRESOURCE(IDI_ROSLOGO), IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR);
             SetWindowLongPtr(hwndDlg, GWL_USERDATA, (DWORD_PTR)pgContext);
 
             pgContext->hBitmap = LoadImage(hDllInstance, MAKEINTRESOURCE(IDI_ROSLOGO), IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR);
-            OnInitLockedDlg(hwndDlg, pgContext);
+            SetLockMessage(hwndDlg, IDC_LOCKMSG, pgContext);
             return TRUE;
         }
         case WM_PAINT:
             return TRUE;
         }
         case WM_PAINT:
index def10e8..fd8da6e 100644 (file)
@@ -162,7 +162,10 @@ GetRegistrySettings(PGINA_CONTEXT pgContext)
 {
     HKEY hKey = NULL;
     LPWSTR lpAutoAdminLogon = NULL;
 {
     HKEY hKey = NULL;
     LPWSTR lpAutoAdminLogon = NULL;
+    LPWSTR lpDontDisplayLastUserName = NULL;
+    LPWSTR lpShutdownWithoutLogon = NULL;
     DWORD dwDisableCAD = 0;
     DWORD dwDisableCAD = 0;
+    DWORD dwSize;
     LONG rc;
 
     rc = RegOpenKeyExW(HKEY_LOCAL_MACHINE,
     LONG rc;
 
     rc = RegOpenKeyExW(HKEY_LOCAL_MACHINE,
@@ -198,6 +201,47 @@ GetRegistrySettings(PGINA_CONTEXT pgContext)
 
     TRACE("bDisableCAD: %s\n", pgContext->bDisableCAD ? "TRUE" : "FALSE");
 
 
     TRACE("bDisableCAD: %s\n", pgContext->bDisableCAD ? "TRUE" : "FALSE");
 
+    pgContext->bShutdownWithoutLogon = TRUE;
+    rc = ReadRegSzKey(hKey,
+                      L"ShutdownWithoutLogon",
+                      &lpShutdownWithoutLogon);
+    if (rc == ERROR_SUCCESS)
+    {
+        if (wcscmp(lpShutdownWithoutLogon, L"0") == 0)
+            pgContext->bShutdownWithoutLogon = FALSE;
+    }
+
+    rc = ReadRegSzKey(hKey,
+                      L"DontDisplayLastUserName",
+                      &lpDontDisplayLastUserName);
+    if (rc == ERROR_SUCCESS)
+    {
+        if (wcscmp(lpDontDisplayLastUserName, L"1") == 0)
+            pgContext->bDontDisplayLastUserName = TRUE;
+    }
+
+    dwSize = 256 * sizeof(WCHAR);
+    rc = RegQueryValueExW(hKey,
+                          L"DefaultUserName",
+                          NULL,
+                          NULL,
+                          (LPBYTE)&pgContext->UserName,
+                          &dwSize);
+
+    dwSize = 256 * sizeof(WCHAR);
+    rc = RegQueryValueExW(hKey,
+                          L"DefaultDomainName",
+                          NULL,
+                          NULL,
+                          (LPBYTE)&pgContext->Domain,
+                          &dwSize);
+
+    if (lpShutdownWithoutLogon != NULL)
+        HeapFree(GetProcessHeap(), 0, lpShutdownWithoutLogon);
+
+    if (lpDontDisplayLastUserName != NULL)
+        HeapFree(GetProcessHeap(), 0, lpDontDisplayLastUserName);
+
     if (lpAutoAdminLogon != NULL)
         HeapFree(GetProcessHeap(), 0, lpAutoAdminLogon);
 
     if (lpAutoAdminLogon != NULL)
         HeapFree(GetProcessHeap(), 0, lpAutoAdminLogon);
 
index 620cdb2..389db60 100644 (file)
@@ -36,6 +36,8 @@ typedef struct
     DWORD AutoLogonState;
     BOOL bDisableCAD;
     BOOL bAutoAdminLogon;
     DWORD AutoLogonState;
     BOOL bDisableCAD;
     BOOL bAutoAdminLogon;
+    BOOL bDontDisplayLastUserName;
+    BOOL bShutdownWithoutLogon;
 
     /* Information to be filled during logon */
     WCHAR UserName[256];
 
     /* Information to be filled during logon */
     WCHAR UserName[256];