Use string resources for ExitWindowsDialog() and RestartDialogEx() to allow

internationalization.

svn path=/trunk/; revision=10097
This commit is contained in:
Gé van Geldorp
2004-07-12 20:53:24 +00:00
parent aa38cd0cd1
commit 55dc46bf13
4 changed files with 81 additions and 32 deletions
+47 -32
View File
@@ -36,6 +36,7 @@
#include "shellapi.h"
#include "shlobj.h"
#include "shell32_main.h"
#include "shresdef.h"
#include "undocshell.h"
typedef struct
@@ -378,31 +379,47 @@ void FillList (HWND hCb, char *pszLatest)
}
/*************************************************************************
* ConfirmDialog [internal]
*
* Put up a confirm box, return TRUE if the user confirmed
*/
static BOOL ConfirmDialog(HWND hWndOwner, UINT PromptId, UINT TitleId)
{
WCHAR Prompt[256];
WCHAR Title[256];
LoadStringW(shell32_hInstance, PromptId, Prompt, sizeof(Prompt) / sizeof(WCHAR));
LoadStringW(shell32_hInstance, TitleId, Title, sizeof(Title) / sizeof(WCHAR));
return MessageBoxW(hWndOwner, Prompt, Title, MB_YESNO|MB_ICONQUESTION) == IDYES;
}
/*************************************************************************
* RestartDialogEx [SHELL32.730]
*/
int WINAPI RestartDialogEx(HWND hwndOwner, LPCWSTR lpwstrReason, UINT uFlags, UINT uReason)
int WINAPI RestartDialogEx(HWND hWndOwner, LPCWSTR lpwstrReason, DWORD uFlags, DWORD uReason)
{
TRACE("(%p)\n", hwndOwner);
TRACE("(%p)\n", hWndOwner);
/*FIXME: use uReason */
if (MessageBoxA(hwndOwner, "Do you want to restart the system?", "Restart", MB_YESNO|MB_ICONQUESTION) == IDYES)
if (ConfirmDialog(hWndOwner, IDS_RESTART_PROMPT, IDS_RESTART_TITLE))
{
if (SHELL_OsIsUnicode())
{
HANDLE hToken;
TOKEN_PRIVILEGES npr = {1, {{{0, 0}, SE_PRIVILEGE_ENABLED}}};
HANDLE hToken;
TOKEN_PRIVILEGES npr;
/* enable shutdown privilege for current process */
OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &hToken);
LookupPrivilegeValueA(0, "SeShutdownPrivilege", &npr.Privileges[0].Luid);
AdjustTokenPrivileges(hToken, FALSE, &npr, 0, 0, 0);
CloseHandle(hToken);
}
ExitWindowsEx(EWX_REBOOT, 0);
/* enable shutdown privilege for current process */
if (OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &hToken))
{
LookupPrivilegeValueA(0, "SeShutdownPrivilege", &npr.Privileges[0].Luid);
npr.PrivilegeCount = 1;
npr.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
AdjustTokenPrivileges(hToken, FALSE, &npr, 0, 0, 0);
CloseHandle(hToken);
}
ExitWindowsEx(EWX_REBOOT, 0);
}
return 0;
@@ -413,9 +430,9 @@ int WINAPI RestartDialogEx(HWND hwndOwner, LPCWSTR lpwstrReason, UINT uFlags, UI
* RestartDialog [SHELL32.59]
*/
int WINAPI RestartDialog(HWND hwndOwner, LPCWSTR lpstrReason, UINT uFlags)
int WINAPI RestartDialog(HWND hWndOwner, LPCWSTR lpstrReason, DWORD uFlags)
{
return RestartDialogEx(hwndOwner, lpstrReason, uFlags, 0);
return RestartDialogEx(hWndOwner, lpstrReason, uFlags, 0);
}
@@ -429,22 +446,20 @@ void WINAPI ExitWindowsDialog (HWND hWndOwner)
{
TRACE("(%p)\n", hWndOwner);
if (MessageBoxA(hWndOwner, "Do you want to shutdown?", "Shutdown", MB_YESNO|MB_ICONQUESTION) == IDYES)
if (ConfirmDialog(hWndOwner, IDS_SHUTDOWN_PROMPT, IDS_SHUTDOWN_TITLE))
{
if (SHELL_OsIsUnicode())
{
HANDLE hToken;
TOKEN_PRIVILEGES npr = {1, {{{0, 0}, SE_PRIVILEGE_ENABLED}}};
HANDLE hToken;
TOKEN_PRIVILEGES npr;
/* enable shutdown privilege for current process */
OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &hToken);
LookupPrivilegeValueA(0, "SeShutdownPrivilege", &npr.Privileges[0].Luid);
AdjustTokenPrivileges(hToken, FALSE, &npr, 0, 0, 0);
CloseHandle(hToken);
ExitWindowsEx(EWX_SHUTDOWN, 0);
}
else
SendMessageA(hWndOwner, WM_QUIT, 0, 0);
/* enable shutdown privilege for current process */
if (OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &hToken))
{
LookupPrivilegeValueA(0, "SeShutdownPrivilege", &npr.Privileges[0].Luid);
npr.PrivilegeCount = 1;
npr.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
AdjustTokenPrivileges(hToken, FALSE, &npr, 0, 0, 0);
CloseHandle(hToken);
}
ExitWindowsEx(EWX_SHUTDOWN, 0);
}
}
+9
View File
@@ -177,3 +177,12 @@ BEGIN
IDS_SHV_COLUMN8 "Name"
IDS_SHV_COLUMN9 "Comments"
END
/* message box strings */
STRINGTABLE DISCARDABLE
{
IDS_RESTART_TITLE "Restart"
IDS_RESTART_PROMPT "Do you want to restart the system?"
IDS_SHUTDOWN_TITLE "Shutdown"
IDS_SHUTDOWN_PROMPT "Do you want to shutdown?"
}
+5
View File
@@ -51,6 +51,11 @@
#define IDS_OVERWRITEFILE_CAPTION 36
#define IDS_OVERWRITEFILE_TEXT 37
#define IDS_RESTART_TITLE 40
#define IDS_RESTART_PROMPT 41
#define IDS_SHUTDOWN_TITLE 42
#define IDS_SHUTDOWN_PROMPT 43
/* browse for folder dialog box */
#define IDD_STATUS 0x3743
#define IDD_TITLE 0x3742
+20
View File
@@ -0,0 +1,20 @@
Index: shell32_En.rc
===================================================================
RCS file: /home/wine/wine/dlls/shell32/shell32_En.rc,v
retrieving revision 1.14
diff -u -r1.14 shell32_En.rc
--- shell32_En.rc 9 Jul 2004 22:51:19 -0000 1.14
+++ shell32_En.rc 12 Jul 2004 21:01:03 -0000
@@ -181,8 +181,8 @@
/* message box strings */
STRINGTABLE DISCARDABLE
{
- IDS_RESTART_TITLE "Restart"
- IDS_RESTART_PROMPT "Do you want to simulate a Windows reboot?"
- IDS_SHUTDOWN_TITLE "Shutdown"
- IDS_SHUTDOWN_PROMPT "Do you want to shutdown your Wine session?"
+ IDS_RESTART_TITLE "Restart"
+ IDS_RESTART_PROMPT "Do you want to restart the system?"
+ IDS_SHUTDOWN_TITLE "Shutdown"
+ IDS_SHUTDOWN_PROMPT "Do you want to shutdown?"
}