mirror of
https://github.com/reactos/reactos.git
synced 2025-06-11 04:47:22 +00:00
[MSGINA]: Code style fixes:
- Use explicit unicode functions; - Just use the hdc field of the PAINTSTRUCT initialized by BeginPaint instead of introducing yet another hdc variable; - Use SetDlgItemTextW instead of GetDlgItem + SetWindowTextW; - Don't hardcode buffer sizes in functions calls; - Use _countof instead of sizeof(foo)/sizeof(foo[0]); - Avoid using raw 'int' variables where possible; - Remove trailing whitespace. ... svn path=/trunk/; revision=72718
This commit is contained in:
parent
40f2bef33b
commit
b5fc396ab8
2 changed files with 156 additions and 124 deletions
|
@ -35,7 +35,7 @@ private:
|
||||||
UCHAR* m_bytes;
|
UCHAR* m_bytes;
|
||||||
int m_step;
|
int m_step;
|
||||||
|
|
||||||
static LRESULT WINAPI Proc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
|
static LRESULT WINAPI WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CDimmedWindow()
|
CDimmedWindow()
|
||||||
|
@ -49,7 +49,7 @@ public:
|
||||||
, m_step(0)
|
, m_step(0)
|
||||||
{
|
{
|
||||||
WNDCLASSEXW wndclass = {sizeof(wndclass)};
|
WNDCLASSEXW wndclass = {sizeof(wndclass)};
|
||||||
wndclass.lpfnWndProc = Proc;
|
wndclass.lpfnWndProc = WndProc;
|
||||||
wndclass.hInstance = hDllInstance;
|
wndclass.hInstance = hDllInstance;
|
||||||
wndclass.hCursor = LoadCursor(0, IDC_ARROW);
|
wndclass.hCursor = LoadCursor(0, IDC_ARROW);
|
||||||
wndclass.lpszClassName = L"DimmedWindowClass";
|
wndclass.lpszClassName = L"DimmedWindowClass";
|
||||||
|
@ -73,9 +73,15 @@ public:
|
||||||
LONG x = GetSystemMetrics(SM_XVIRTUALSCREEN);
|
LONG x = GetSystemMetrics(SM_XVIRTUALSCREEN);
|
||||||
LONG y = GetSystemMetrics(SM_YVIRTUALSCREEN);
|
LONG y = GetSystemMetrics(SM_YVIRTUALSCREEN);
|
||||||
|
|
||||||
m_hwnd = CreateWindowExW(WS_EX_TOPMOST, L"DimmedWindowClass", NULL, WS_POPUP,
|
m_hwnd = CreateWindowExW(WS_EX_TOPMOST,
|
||||||
x, y, m_width, m_height,
|
L"DimmedWindowClass",
|
||||||
NULL, NULL, hDllInstance, (LPVOID)this);
|
NULL,
|
||||||
|
WS_POPUP,
|
||||||
|
x, y,
|
||||||
|
m_width, m_height,
|
||||||
|
NULL, NULL,
|
||||||
|
hDllInstance,
|
||||||
|
(LPVOID)this);
|
||||||
}
|
}
|
||||||
|
|
||||||
~CDimmedWindow()
|
~CDimmedWindow()
|
||||||
|
@ -115,7 +121,8 @@ public:
|
||||||
{
|
{
|
||||||
Capture();
|
Capture();
|
||||||
|
|
||||||
ShowWindow(m_hwnd, SW_SHOWNA);
|
ShowWindow(m_hwnd, SW_SHOW);
|
||||||
|
SetForegroundWindow(m_hwnd);
|
||||||
EnableWindow(m_hwnd, FALSE);
|
EnableWindow(m_hwnd, FALSE);
|
||||||
|
|
||||||
SetTimer(m_hwnd, FADE_TIMER_ID, 200, NULL);
|
SetTimer(m_hwnd, FADE_TIMER_ID, 200, NULL);
|
||||||
|
@ -191,58 +198,62 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
LRESULT WINAPI CDimmedWindow::Proc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
LRESULT WINAPI CDimmedWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
switch(uMsg)
|
switch (uMsg)
|
||||||
{
|
{
|
||||||
case WM_NCCREATE:
|
case WM_NCCREATE:
|
||||||
{
|
{
|
||||||
LPCREATESTRUCT lpcs = reinterpret_cast<LPCREATESTRUCT>(lParam);
|
LPCREATESTRUCT lpcs = reinterpret_cast<LPCREATESTRUCT>(lParam);
|
||||||
CDimmedWindow* info = static_cast<CDimmedWindow*>(lpcs->lpCreateParams);
|
CDimmedWindow* info = static_cast<CDimmedWindow*>(lpcs->lpCreateParams);
|
||||||
SetWindowLongPtr(hWnd, GWLP_USERDATA, (LONG)info);
|
SetWindowLongPtrW(hWnd, GWLP_USERDATA, (LONG_PTR)info);
|
||||||
SetTimer(hWnd, INIT_TIMER_ID, 50, NULL);
|
SetTimer(hWnd, INIT_TIMER_ID, 50, NULL);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case WM_PAINT:
|
case WM_PAINT:
|
||||||
{
|
{
|
||||||
CDimmedWindow* info = reinterpret_cast<CDimmedWindow*>(GetWindowLongPtr(hWnd, GWLP_USERDATA));
|
CDimmedWindow* info = reinterpret_cast<CDimmedWindow*>(GetWindowLongPtrW(hWnd, GWLP_USERDATA));
|
||||||
if (info)
|
if (info)
|
||||||
{
|
{
|
||||||
PAINTSTRUCT paint;
|
PAINTSTRUCT ps;
|
||||||
HDC hdc = BeginPaint(hWnd, &paint);
|
BeginPaint(hWnd, &ps);
|
||||||
info->Blt(hdc);
|
info->Blt(ps.hdc);
|
||||||
EndPaint(hWnd, &paint);
|
EndPaint(hWnd, &ps);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
case WM_TIMER:
|
case WM_TIMER:
|
||||||
|
{
|
||||||
if (wParam == INIT_TIMER_ID)
|
if (wParam == INIT_TIMER_ID)
|
||||||
{
|
{
|
||||||
CDimmedWindow* info = reinterpret_cast<CDimmedWindow*>(GetWindowLongPtr(hWnd, GWLP_USERDATA));
|
CDimmedWindow* info = reinterpret_cast<CDimmedWindow*>(GetWindowLongPtrW(hWnd, GWLP_USERDATA));
|
||||||
KillTimer(hWnd, INIT_TIMER_ID);
|
KillTimer(hWnd, INIT_TIMER_ID);
|
||||||
info->Init();
|
info->Init();
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
if (wParam == FADE_TIMER_ID)
|
else if (wParam == FADE_TIMER_ID)
|
||||||
{
|
{
|
||||||
CDimmedWindow* info = reinterpret_cast<CDimmedWindow*>(GetWindowLongPtr(hWnd, GWLP_USERDATA));
|
CDimmedWindow* info = reinterpret_cast<CDimmedWindow*>(GetWindowLongPtrW(hWnd, GWLP_USERDATA));
|
||||||
if (info && info->Step())
|
if (info && info->Step())
|
||||||
InvalidateRect(hWnd, NULL, TRUE);
|
InvalidateRect(hWnd, NULL, TRUE);
|
||||||
else
|
else
|
||||||
KillTimer(hWnd, FADE_TIMER_ID);
|
KillTimer(hWnd, FADE_TIMER_ID);
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return DefWindowProc(hWnd, uMsg, wParam, lParam);
|
return DefWindowProc(hWnd, uMsg, wParam, lParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
extern "C"
|
extern "C"
|
||||||
HRESULT WINAPI
|
HRESULT WINAPI
|
||||||
ShellDimScreen (void** pUnknown, HWND* hWindow)
|
ShellDimScreen(void** pUnknown, HWND* hWindow)
|
||||||
{
|
{
|
||||||
CComObject<CDimmedWindow> *pWindow;
|
CComObject<CDimmedWindow> *pWindow;
|
||||||
HRESULT hr = CComObject<CDimmedWindow>::CreateInstance(&pWindow);
|
HRESULT hr = CComObject<CDimmedWindow>::CreateInstance(&pWindow);
|
||||||
|
|
|
@ -13,27 +13,35 @@
|
||||||
#include <winreg.h>
|
#include <winreg.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
int g_shutdownCode = 0;
|
DWORD g_shutdownCode = 0;
|
||||||
BOOL g_logoffHideState = FALSE;
|
BOOL g_logoffHideState = FALSE;
|
||||||
|
|
||||||
int LoadShutdownSelState(void)
|
static DWORD
|
||||||
|
LoadShutdownSelState(VOID)
|
||||||
{
|
{
|
||||||
HKEY hKey;
|
HKEY hKey;
|
||||||
|
LONG lRet;
|
||||||
DWORD dwValue, dwTemp, dwSize;
|
DWORD dwValue, dwTemp, dwSize;
|
||||||
|
|
||||||
|
/* Default to shutdown */
|
||||||
/* default to shutdown */
|
|
||||||
dwValue = 1;
|
dwValue = 1;
|
||||||
|
|
||||||
if (RegOpenKeyExW(HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer", 0, KEY_QUERY_VALUE, &hKey) != ERROR_SUCCESS)
|
lRet = RegOpenKeyExW(HKEY_CURRENT_USER,
|
||||||
{
|
L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer",
|
||||||
|
0, KEY_QUERY_VALUE, &hKey);
|
||||||
|
if (lRet != ERROR_SUCCESS)
|
||||||
return dwValue;
|
return dwValue;
|
||||||
}
|
|
||||||
|
|
||||||
dwSize = sizeof(dwTemp);
|
dwSize = sizeof(dwTemp);
|
||||||
if (RegQueryValueExW(hKey, L"Shutdown Setting", NULL, NULL, (LPBYTE)&dwTemp, &dwSize) == ERROR_SUCCESS)
|
lRet = RegQueryValueExW(hKey,
|
||||||
|
L"Shutdown Setting",
|
||||||
|
NULL, NULL,
|
||||||
|
(LPBYTE)&dwTemp, &dwSize);
|
||||||
|
RegCloseKey(hKey);
|
||||||
|
|
||||||
|
if (lRet == ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
switch(dwTemp)
|
switch (dwTemp)
|
||||||
{
|
{
|
||||||
case 0x01: /* Log off */
|
case 0x01: /* Log off */
|
||||||
dwValue = 0;
|
dwValue = 0;
|
||||||
|
@ -57,23 +65,26 @@ int LoadShutdownSelState(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RegCloseKey(hKey);
|
|
||||||
|
|
||||||
return dwValue;
|
return dwValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID SaveShutdownSelState(int ShutdownCode)
|
static VOID
|
||||||
|
SaveShutdownSelState(DWORD ShutdownCode)
|
||||||
{
|
{
|
||||||
HKEY hKey;
|
HKEY hKey;
|
||||||
DWORD dwValue = 0;
|
DWORD dwValue = 0;
|
||||||
|
|
||||||
|
if (RegCreateKeyExW(HKEY_CURRENT_USER,
|
||||||
if (RegCreateKeyExW(HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer", 0, NULL, REG_OPTION_NON_VOLATILE, KEY_SET_VALUE, NULL, &hKey, NULL) != ERROR_SUCCESS)
|
L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer",
|
||||||
|
0, NULL,
|
||||||
|
REG_OPTION_NON_VOLATILE,
|
||||||
|
KEY_SET_VALUE,
|
||||||
|
NULL, &hKey, NULL) != ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch(ShutdownCode)
|
switch (ShutdownCode)
|
||||||
{
|
{
|
||||||
case 0: /* Log off */
|
case 0: /* Log off */
|
||||||
dwValue = 0x01;
|
dwValue = 0x01;
|
||||||
|
@ -96,31 +107,34 @@ VOID SaveShutdownSelState(int ShutdownCode)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
RegSetValueExW(hKey, L"Shutdown Setting", 0, REG_DWORD, (const BYTE*)&dwValue, sizeof(dwValue));
|
RegSetValueExW(hKey,
|
||||||
|
L"Shutdown Setting",
|
||||||
|
0, REG_DWORD,
|
||||||
|
(LPBYTE)&dwValue, sizeof(dwValue));
|
||||||
RegCloseKey(hKey);
|
RegCloseKey(hKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID UpdateShutdownShellDesc(HWND hwnd)
|
static VOID
|
||||||
|
UpdateShutdownShellDesc(HWND hWnd)
|
||||||
{
|
{
|
||||||
|
UINT DescId = 0;
|
||||||
|
DWORD ShutdownCode = 0;
|
||||||
WCHAR tmpBuffer[256];
|
WCHAR tmpBuffer[256];
|
||||||
UINT shutdownDescId = 0;
|
|
||||||
HWND shutdownHwnd = GetDlgItem(hwnd, IDC_SHUTDOWN_DESCRIPTION);
|
|
||||||
int shutdownCode = 0;
|
|
||||||
|
|
||||||
shutdownCode = SendDlgItemMessageW(hwnd, IDC_SHUTDOWN_LIST, CB_GETCURSEL, 0, 0);
|
ShutdownCode = SendDlgItemMessageW(hWnd, IDC_SHUTDOWN_LIST, CB_GETCURSEL, 0, 0);
|
||||||
|
|
||||||
if(!g_logoffHideState)
|
if (!g_logoffHideState)
|
||||||
{
|
{
|
||||||
switch (shutdownCode)
|
switch (ShutdownCode)
|
||||||
{
|
{
|
||||||
case 0: /* Log off */
|
case 0: /* Log off */
|
||||||
shutdownDescId = IDS_SHUTDOWN_LOGOFF_DESC;
|
DescId = IDS_SHUTDOWN_LOGOFF_DESC;
|
||||||
break;
|
break;
|
||||||
case 1: /* Shut down */
|
case 1: /* Shut down */
|
||||||
shutdownDescId = IDS_SHUTDOWN_SHUTDOWN_DESC;
|
DescId = IDS_SHUTDOWN_SHUTDOWN_DESC;
|
||||||
break;
|
break;
|
||||||
case 2: /* Restart */
|
case 2: /* Restart */
|
||||||
shutdownDescId = IDS_SHUTDOWN_RESTART_DESC;
|
DescId = IDS_SHUTDOWN_RESTART_DESC;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -128,32 +142,32 @@ VOID UpdateShutdownShellDesc(HWND hwnd)
|
||||||
|
|
||||||
if (IsPwrSuspendAllowed())
|
if (IsPwrSuspendAllowed())
|
||||||
{
|
{
|
||||||
if (shutdownCode == 3) /* Sleep */
|
if (ShutdownCode == 3) /* Sleep */
|
||||||
{
|
{
|
||||||
shutdownDescId = IDS_SHUTDOWN_SLEEP_DESC;
|
DescId = IDS_SHUTDOWN_SLEEP_DESC;
|
||||||
}
|
}
|
||||||
else if (shutdownCode == 4) /* Hibernate */
|
else if (ShutdownCode == 4) /* Hibernate */
|
||||||
{
|
{
|
||||||
shutdownDescId = IDS_SHUTDOWN_HIBERNATE_DESC;
|
DescId = IDS_SHUTDOWN_HIBERNATE_DESC;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (shutdownCode == 3) /* Hibernate */
|
if (ShutdownCode == 3) /* Hibernate */
|
||||||
{
|
{
|
||||||
shutdownDescId = IDS_SHUTDOWN_SLEEP_DESC;
|
DescId = IDS_SHUTDOWN_SLEEP_DESC;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
switch (shutdownCode)
|
switch (ShutdownCode)
|
||||||
{
|
{
|
||||||
case 0: /* Shut down */
|
case 0: /* Shut down */
|
||||||
shutdownDescId = IDS_SHUTDOWN_SHUTDOWN_DESC;
|
DescId = IDS_SHUTDOWN_SHUTDOWN_DESC;
|
||||||
break;
|
break;
|
||||||
case 1: /* Restart */
|
case 1: /* Restart */
|
||||||
shutdownDescId = IDS_SHUTDOWN_RESTART_DESC;
|
DescId = IDS_SHUTDOWN_RESTART_DESC;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -161,35 +175,36 @@ VOID UpdateShutdownShellDesc(HWND hwnd)
|
||||||
|
|
||||||
if (IsPwrSuspendAllowed())
|
if (IsPwrSuspendAllowed())
|
||||||
{
|
{
|
||||||
if (shutdownCode == 2) /* Sleep */
|
if (ShutdownCode == 2) /* Sleep */
|
||||||
{
|
{
|
||||||
shutdownDescId = IDS_SHUTDOWN_SLEEP_DESC;
|
DescId = IDS_SHUTDOWN_SLEEP_DESC;
|
||||||
}
|
}
|
||||||
else if (shutdownCode == 3) /* Hibernate */
|
else if (ShutdownCode == 3) /* Hibernate */
|
||||||
{
|
{
|
||||||
shutdownDescId = IDS_SHUTDOWN_HIBERNATE_DESC;
|
DescId = IDS_SHUTDOWN_HIBERNATE_DESC;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (shutdownCode == 2) /* Hibernate */
|
if (ShutdownCode == 2) /* Hibernate */
|
||||||
{
|
{
|
||||||
shutdownDescId = IDS_SHUTDOWN_SLEEP_DESC;
|
DescId = IDS_SHUTDOWN_SLEEP_DESC;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LoadStringW(hDllInstance, shutdownDescId, tmpBuffer, sizeof(tmpBuffer));
|
LoadStringW(hDllInstance, DescId, tmpBuffer, _countof(tmpBuffer));
|
||||||
SetWindowTextW(shutdownHwnd, tmpBuffer);
|
SetDlgItemTextW(hWnd, IDC_SHUTDOWN_DESCRIPTION, tmpBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL CALLBACK ExitWindowsDialogShellProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
|
BOOL CALLBACK
|
||||||
|
ExitWindowsDialogShellProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
PGINA_CONTEXT pgContext;
|
PGINA_CONTEXT pgContext;
|
||||||
|
|
||||||
pgContext = (PGINA_CONTEXT)GetWindowLongPtr(hwnd, GWL_USERDATA);
|
pgContext = (PGINA_CONTEXT)GetWindowLongPtrW(hWnd, GWLP_USERDATA);
|
||||||
|
|
||||||
switch (Message)
|
switch (uMsg)
|
||||||
{
|
{
|
||||||
case WM_INITDIALOG:
|
case WM_INITDIALOG:
|
||||||
{
|
{
|
||||||
|
@ -206,20 +221,20 @@ BOOL CALLBACK ExitWindowsDialogShellProc(HWND hwnd, UINT Message, WPARAM wParam,
|
||||||
WARN("pgContext is NULL, branding bitmaps will not be displayed.\n");
|
WARN("pgContext is NULL, branding bitmaps will not be displayed.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
SetWindowLongPtr(hwnd, GWL_USERDATA, (DWORD_PTR)pgContext);
|
SetWindowLongPtrW(hWnd, GWLP_USERDATA, (LONG_PTR)pgContext);
|
||||||
|
|
||||||
/* Clears the content before it's used */
|
/* Clear the content before it's used */
|
||||||
SendDlgItemMessageW(hwnd, IDC_SHUTDOWN_LIST, CB_RESETCONTENT, 0, 0);
|
SendDlgItemMessageW(hWnd, IDC_SHUTDOWN_LIST, CB_RESETCONTENT, 0, 0);
|
||||||
|
|
||||||
lastState = LoadShutdownSelState();
|
lastState = LoadShutdownSelState();
|
||||||
|
|
||||||
if(!g_logoffHideState)
|
if (!g_logoffHideState)
|
||||||
{
|
{
|
||||||
/* Log off */
|
/* Log off */
|
||||||
LoadStringW(hDllInstance, IDS_SHUTDOWN_LOGOFF, tmpBuffer, sizeof(tmpBuffer)/sizeof(WCHAR));
|
LoadStringW(hDllInstance, IDS_SHUTDOWN_LOGOFF, tmpBuffer, _countof(tmpBuffer));
|
||||||
GetUserNameW(userBuffer, &userBufferSize);
|
GetUserNameW(userBuffer, &userBufferSize);
|
||||||
StringCchPrintfW(tmpBuffer2, 512, tmpBuffer, userBuffer);
|
StringCchPrintfW(tmpBuffer2, _countof(tmpBuffer2), tmpBuffer, userBuffer);
|
||||||
tmpSelect = SendDlgItemMessageW(hwnd, IDC_SHUTDOWN_LIST, CB_ADDSTRING, 0, (LPARAM)tmpBuffer2);
|
tmpSelect = SendDlgItemMessageW(hWnd, IDC_SHUTDOWN_LIST, CB_ADDSTRING, 0, (LPARAM)tmpBuffer2);
|
||||||
if (lastState == 0)
|
if (lastState == 0)
|
||||||
{
|
{
|
||||||
defSelect = tmpSelect;
|
defSelect = tmpSelect;
|
||||||
|
@ -227,16 +242,16 @@ BOOL CALLBACK ExitWindowsDialogShellProc(HWND hwnd, UINT Message, WPARAM wParam,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Shut down - DEFAULT */
|
/* Shut down - DEFAULT */
|
||||||
LoadStringW(hDllInstance, IDS_SHUTDOWN_SHUTDOWN, tmpBuffer, sizeof(tmpBuffer)/sizeof(WCHAR));
|
LoadStringW(hDllInstance, IDS_SHUTDOWN_SHUTDOWN, tmpBuffer, _countof(tmpBuffer));
|
||||||
tmpSelect = SendDlgItemMessageW(hwnd, IDC_SHUTDOWN_LIST, CB_ADDSTRING, 0, (LPARAM)tmpBuffer);
|
tmpSelect = SendDlgItemMessageW(hWnd, IDC_SHUTDOWN_LIST, CB_ADDSTRING, 0, (LPARAM)tmpBuffer);
|
||||||
if (lastState == 1)
|
if (lastState == 1)
|
||||||
{
|
{
|
||||||
defSelect = tmpSelect;
|
defSelect = tmpSelect;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Restart */
|
/* Restart */
|
||||||
LoadStringW(hDllInstance, IDS_SHUTDOWN_RESTART, tmpBuffer, sizeof(tmpBuffer)/sizeof(WCHAR));
|
LoadStringW(hDllInstance, IDS_SHUTDOWN_RESTART, tmpBuffer, _countof(tmpBuffer));
|
||||||
tmpSelect = SendDlgItemMessageW(hwnd, IDC_SHUTDOWN_LIST, CB_ADDSTRING, 0, (LPARAM)tmpBuffer);
|
tmpSelect = SendDlgItemMessageW(hWnd, IDC_SHUTDOWN_LIST, CB_ADDSTRING, 0, (LPARAM)tmpBuffer);
|
||||||
if (lastState == 2)
|
if (lastState == 2)
|
||||||
{
|
{
|
||||||
defSelect = tmpSelect;
|
defSelect = tmpSelect;
|
||||||
|
@ -245,8 +260,8 @@ BOOL CALLBACK ExitWindowsDialogShellProc(HWND hwnd, UINT Message, WPARAM wParam,
|
||||||
/* Sleep */
|
/* Sleep */
|
||||||
if (IsPwrSuspendAllowed())
|
if (IsPwrSuspendAllowed())
|
||||||
{
|
{
|
||||||
LoadStringW(hDllInstance, IDS_SHUTDOWN_SLEEP, tmpBuffer, sizeof(tmpBuffer)/sizeof(WCHAR));
|
LoadStringW(hDllInstance, IDS_SHUTDOWN_SLEEP, tmpBuffer, _countof(tmpBuffer));
|
||||||
tmpSelect = SendDlgItemMessageW(hwnd, IDC_SHUTDOWN_LIST, CB_ADDSTRING, 0, (LPARAM)tmpBuffer);
|
tmpSelect = SendDlgItemMessageW(hWnd, IDC_SHUTDOWN_LIST, CB_ADDSTRING, 0, (LPARAM)tmpBuffer);
|
||||||
if (lastState == 3)
|
if (lastState == 3)
|
||||||
{
|
{
|
||||||
defSelect = tmpSelect;
|
defSelect = tmpSelect;
|
||||||
|
@ -256,8 +271,8 @@ BOOL CALLBACK ExitWindowsDialogShellProc(HWND hwnd, UINT Message, WPARAM wParam,
|
||||||
/* Hibernate */
|
/* Hibernate */
|
||||||
if (IsPwrHibernateAllowed())
|
if (IsPwrHibernateAllowed())
|
||||||
{
|
{
|
||||||
LoadStringW(hDllInstance, IDS_SHUTDOWN_HIBERNATE, tmpBuffer, sizeof(tmpBuffer)/sizeof(WCHAR));
|
LoadStringW(hDllInstance, IDS_SHUTDOWN_HIBERNATE, tmpBuffer, _countof(tmpBuffer));
|
||||||
tmpSelect = SendDlgItemMessageW(hwnd, IDC_SHUTDOWN_LIST, CB_ADDSTRING, 0, (LPARAM)tmpBuffer);
|
tmpSelect = SendDlgItemMessageW(hWnd, IDC_SHUTDOWN_LIST, CB_ADDSTRING, 0, (LPARAM)tmpBuffer);
|
||||||
if (lastState == 4)
|
if (lastState == 4)
|
||||||
{
|
{
|
||||||
defSelect = tmpSelect;
|
defSelect = tmpSelect;
|
||||||
|
@ -265,55 +280,61 @@ BOOL CALLBACK ExitWindowsDialogShellProc(HWND hwnd, UINT Message, WPARAM wParam,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Sets the default shut down selection */
|
/* Sets the default shut down selection */
|
||||||
SendDlgItemMessageW(hwnd, IDC_SHUTDOWN_LIST, CB_SETCURSEL, defSelect, 0);
|
SendDlgItemMessageW(hWnd, IDC_SHUTDOWN_LIST, CB_SETCURSEL, defSelect, 0);
|
||||||
|
|
||||||
/* Updates the choice description based on the current selection */
|
/* Updates the choice description based on the current selection */
|
||||||
UpdateShutdownShellDesc(hwnd);
|
UpdateShutdownShellDesc(hWnd);
|
||||||
|
|
||||||
/* Draw the logo graphic */
|
/* Draw the logo bitmap */
|
||||||
if (pgContext)
|
if (pgContext)
|
||||||
pgContext->hBitmap = LoadImage(hDllInstance, MAKEINTRESOURCE(IDI_ROSLOGO), IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR);
|
pgContext->hBitmap = LoadImageW(hDllInstance, MAKEINTRESOURCEW(IDI_ROSLOGO), IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
case WM_PAINT:
|
|
||||||
{
|
|
||||||
PAINTSTRUCT ps;
|
|
||||||
HDC hdc;
|
|
||||||
if (pgContext && pgContext->hBitmap)
|
|
||||||
{
|
|
||||||
hdc = BeginPaint(hwnd, &ps);
|
|
||||||
DrawStateW(hdc, NULL, NULL, (LPARAM)pgContext->hBitmap, (WPARAM)0, 0, 0, 0, 0, DST_BITMAP);
|
|
||||||
EndPaint(hwnd, &ps);
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
case WM_DESTROY:
|
case WM_DESTROY:
|
||||||
{
|
{
|
||||||
if (pgContext)
|
if (pgContext)
|
||||||
DeleteObject(pgContext->hBitmap);
|
DeleteObject(pgContext->hBitmap);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case WM_PAINT:
|
||||||
|
{
|
||||||
|
PAINTSTRUCT ps;
|
||||||
|
if (pgContext && pgContext->hBitmap)
|
||||||
|
{
|
||||||
|
BeginPaint(hWnd, &ps);
|
||||||
|
DrawStateW(ps.hdc, NULL, NULL, (LPARAM)pgContext->hBitmap, 0, 0, 0, 0, 0, DST_BITMAP);
|
||||||
|
EndPaint(hWnd, &ps);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
case WM_COMMAND:
|
case WM_COMMAND:
|
||||||
switch(LOWORD(wParam))
|
switch (LOWORD(wParam))
|
||||||
{
|
{
|
||||||
case IDOK:
|
case IDOK:
|
||||||
g_shutdownCode = SendDlgItemMessageW(hwnd, IDC_SHUTDOWN_LIST, CB_GETCURSEL, (WPARAM)0, (LPARAM)0);
|
g_shutdownCode = SendDlgItemMessageW(hWnd, IDC_SHUTDOWN_LIST, CB_GETCURSEL, 0, 0);
|
||||||
SaveShutdownSelState(g_shutdownCode);
|
SaveShutdownSelState(g_shutdownCode);
|
||||||
EndDialog(hwnd, IDOK);
|
EndDialog(hWnd, IDOK);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IDCANCEL:
|
case IDCANCEL:
|
||||||
EndDialog(hwnd, IDCANCEL);
|
EndDialog(hWnd, IDCANCEL);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IDHELP:
|
case IDHELP:
|
||||||
EndDialog(hwnd, IDHELP);
|
EndDialog(hWnd, IDHELP);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IDC_SHUTDOWN_LIST:
|
case IDC_SHUTDOWN_LIST:
|
||||||
UpdateShutdownShellDesc(hwnd);
|
UpdateShutdownShellDesc(hWnd);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -344,20 +365,20 @@ ShellShutdownDialog(
|
||||||
BOOL bHideLogoff)
|
BOOL bHideLogoff)
|
||||||
{
|
{
|
||||||
GINA_CONTEXT pgContext = { 0 };
|
GINA_CONTEXT pgContext = { 0 };
|
||||||
int dlgValue = 0;
|
INT_PTR dlgValue = 0;
|
||||||
|
|
||||||
g_logoffHideState = bHideLogoff;
|
|
||||||
|
|
||||||
UNREFERENCED_PARAMETER(lpUsername);
|
UNREFERENCED_PARAMETER(lpUsername);
|
||||||
|
|
||||||
// Loads the shut down dialog box
|
g_logoffHideState = bHideLogoff;
|
||||||
dlgValue = DialogBoxParam(hDllInstance,
|
|
||||||
MAKEINTRESOURCE(IDD_SHUTDOWN_SHELL),
|
/* Load the shut down dialog box */
|
||||||
|
dlgValue = DialogBoxParamW(hDllInstance,
|
||||||
|
MAKEINTRESOURCEW(IDD_SHUTDOWN_SHELL),
|
||||||
hParent,
|
hParent,
|
||||||
ExitWindowsDialogShellProc,
|
ExitWindowsDialogShellProc,
|
||||||
(LPARAM)&pgContext);
|
(LPARAM)&pgContext);
|
||||||
|
|
||||||
// Determines what to do based on user selection
|
/* Determine what to do based on user selection */
|
||||||
if (dlgValue == IDOK)
|
if (dlgValue == IDOK)
|
||||||
{
|
{
|
||||||
switch (g_shutdownCode)
|
switch (g_shutdownCode)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue