notepad: Fix a string resource so its format placeholders can be reordered.

Francois Gouget fgouget at free.fr
Wed Nov 23 17:26:30 CST 2011


---
 programs/notepad/dialog.c   |   20 +++++++++++++-------
 programs/notepad/notepad.rc |    4 ++--
 2 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/programs/notepad/dialog.c b/programs/notepad/dialog.c
index 94410bd..ec30a8f 100644
--- a/programs/notepad/dialog.c
+++ b/programs/notepad/dialog.c
@@ -153,19 +153,25 @@ static int AlertFileNotSaved(LPCWSTR szFileName)
 
 static int AlertUnicodeCharactersLost(LPCWSTR szFileName)
 {
+    WCHAR szCaption[MAX_STRING_LEN];
     WCHAR szMsgFormat[MAX_STRING_LEN];
     WCHAR szEnc[MAX_STRING_LEN];
-    WCHAR szMsg[ARRAY_SIZE(szMsgFormat) + MAX_PATH + ARRAY_SIZE(szEnc)];
-    WCHAR szCaption[MAX_STRING_LEN];
+    WCHAR* szMsg;
+    DWORD_PTR args[2];
+    int rc;
 
+    LoadStringW(Globals.hInstance, STRING_NOTEPAD, szCaption,
+                ARRAY_SIZE(szCaption));
     LoadStringW(Globals.hInstance, STRING_LOSS_OF_UNICODE_CHARACTERS,
                 szMsgFormat, ARRAY_SIZE(szMsgFormat));
     load_encoding_name(ENCODING_ANSI, szEnc, ARRAY_SIZE(szEnc));
-    wnsprintfW(szMsg, ARRAY_SIZE(szMsg), szMsgFormat, szFileName, szEnc);
-    LoadStringW(Globals.hInstance, STRING_NOTEPAD, szCaption,
-                ARRAY_SIZE(szCaption));
-    return MessageBoxW(Globals.hMainWnd, szMsg, szCaption,
-                       MB_OKCANCEL|MB_ICONEXCLAMATION);
+    args[0] = (DWORD_PTR)szFileName;
+    args[1] = (DWORD_PTR)szEnc;
+    FormatMessageW(FORMAT_MESSAGE_FROM_STRING|FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_ARGUMENT_ARRAY, szMsgFormat, 0, 0, (LPWSTR)&szMsg, 0, (__ms_va_list*)args);
+    rc = MessageBoxW(Globals.hMainWnd, szMsg, szCaption,
+                     MB_OKCANCEL|MB_ICONEXCLAMATION);
+    LocalFree(szMsg);
+    return rc;
 }
 
 /**
diff --git a/programs/notepad/notepad.rc b/programs/notepad/notepad.rc
index 4a7f7f1..6f49ddc 100644
--- a/programs/notepad/notepad.rc
+++ b/programs/notepad/notepad.rc
@@ -91,9 +91,9 @@ STRING_UNICODE_LE,     "Unicode (UTF-16)"
 STRING_UNICODE_BE,     "Unicode (UTF-16 big-endian)"
 STRING_UTF8,           "Unicode (UTF-8)"
 
-STRING_LOSS_OF_UNICODE_CHARACTERS,         "%s\n\
+STRING_LOSS_OF_UNICODE_CHARACTERS,         "%1\n\
 This file contains Unicode characters which will be lost if\n\
-you save this file in the %s encoding.\n\
+you save this file in the %2 encoding.\n\
 To keep these characters, click Cancel, and then select\n\
 one of the Unicode options in the Encoding drop down list.\n\
 Continue?"
-- 
1.7.7.1




More information about the wine-patches mailing list