Author: mjansen
Date: Sun Sep  4 14:18:41 2016
New Revision: 72573

URL: http://svn.reactos.org/svn/reactos?rev=72573&view=rev
Log:
[SHELL32] Use the new ShellDimScreen function to fade the background on logoff 
/ shutdown dialogs. CORE-11422 #resolve

Modified:
    trunk/reactos/dll/win32/shell32/dialogs/dialogs.cpp

Modified: trunk/reactos/dll/win32/shell32/dialogs/dialogs.cpp
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shell32/dialogs/dialogs.cpp?rev=72573&r1=72572&r2=72573&view=diff
==============================================================================
--- trunk/reactos/dll/win32/shell32/dialogs/dialogs.cpp [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/shell32/dialogs/dialogs.cpp [iso-8859-1] Sun Sep  4 
14:18:41 2016
@@ -810,6 +810,27 @@
   return MessageBoxW(hWndOwner, Prompt, Title, MB_YESNO|MB_ICONQUESTION) == 
IDYES;
 }
 
+typedef HRESULT (__stdcall *tShellDimScreen) (IUnknown** Unknown, HWND* 
hWindow);
+
+BOOL
+CallShellDimScreen(IUnknown** pUnknown, HWND* hWindow)
+{
+    static tShellDimScreen ShellDimScreen;
+    static BOOL Initialized = FALSE;
+    if (!Initialized)
+    {
+        HMODULE mod = LoadLibrary(TEXT("msgina.dll"));
+        ShellDimScreen = (tShellDimScreen)GetProcAddress(mod, 
MAKEINTRESOURCEA(16));
+        Initialized = TRUE;
+    }
+
+    HRESULT hr = E_FAIL;
+    if (ShellDimScreen)
+        hr = ShellDimScreen(pUnknown, hWindow);
+    return SUCCEEDED(hr);
+}
+
+
 
 /*************************************************************************
  * RestartDialogEx                [SHELL32.730]
@@ -819,8 +840,13 @@
 {
     TRACE("(%p)\n", hWndOwner);
 
+    CComPtr<IUnknown> fadeHandler;
+    HWND parent;
+    if (!CallShellDimScreen(&fadeHandler, &parent))
+        parent = hWndOwner;
+
     /* FIXME: use lpwstrReason */
-    if (ConfirmDialog(hWndOwner, IDS_RESTART_PROMPT, IDS_RESTART_TITLE))
+    if (ConfirmDialog(parent, IDS_RESTART_PROMPT, IDS_RESTART_TITLE))
     {
         HANDLE hToken;
         TOKEN_PRIVILEGES npr;
@@ -881,7 +907,12 @@
 
 EXTERN_C int WINAPI LogoffWindowsDialog(HWND hWndOwner)
 {
-    DialogBox(shell32_hInstance, MAKEINTRESOURCE(IDD_LOG_OFF), hWndOwner, 
LogOffDialogProc);
+    CComPtr<IUnknown> fadeHandler;
+    HWND parent;
+    if (!CallShellDimScreen(&fadeHandler, &parent))
+        parent = hWndOwner;
+
+    DialogBox(shell32_hInstance, MAKEINTRESOURCE(IDD_LOG_OFF), parent, 
LogOffDialogProc);
     return 0;
 }
 
@@ -952,12 +983,17 @@
 
     TRACE("(%p)\n", hWndOwner);
 
+    CComPtr<IUnknown> fadeHandler;
+    HWND parent;
+    if (!CallShellDimScreen(&fadeHandler, &parent))
+        parent = hWndOwner;
+
     /* If the DLL cannot be found for any reason, then it simply uses a
        dialog box to ask if the user wants to shut down the computer. */
     if(!msginaDll)
     {
         TRACE("Unable to load msgina.dll.\n");
-        ExitWindowsDialog_backup(hWndOwner);
+        ExitWindowsDialog_backup(parent);
         return;
     }
 
@@ -966,7 +1002,7 @@
     if(pShellShutdownDialog)
     {
         /* Actually call the function */
-        DWORD returnValue = pShellShutdownDialog(hWndOwner, NULL, FALSE);
+        DWORD returnValue = pShellShutdownDialog(parent, NULL, FALSE);
 
         switch(returnValue)
         {
@@ -1019,6 +1055,6 @@
         /* If the function cannot be found, then revert to using the backup 
solution */
         TRACE("Unable to find the 'ShellShutdownDialog' function");
         FreeLibrary(msginaDll);
-        ExitWindowsDialog_backup(hWndOwner);
-    }
-}
+        ExitWindowsDialog_backup(parent);
+    }
+}


Reply via email to