From 91f6409c6499e81631b466467aa2bc5450027764 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Wed, 6 Nov 2024 21:47:02 +0100 Subject: [PATCH] wordpad: Use wide character string literals. --- programs/wordpad/olecallback.c | 3 +- programs/wordpad/print.c | 38 ++++------- programs/wordpad/registry.c | 108 +++++++++++--------------------- programs/wordpad/wordpad.c | 111 ++++++++++++--------------------- 4 files changed, 93 insertions(+), 167 deletions(-) diff --git a/programs/wordpad/olecallback.c b/programs/wordpad/olecallback.c index e3bee7f850b..34052ba230f 100644 --- a/programs/wordpad/olecallback.c +++ b/programs/wordpad/olecallback.c @@ -74,10 +74,9 @@ static HRESULT STDMETHODCALLTYPE RichEditOleCallback_GetNewStorage( LPSTORAGE *lplpstg) { WCHAR name[32]; - static const WCHAR template[] = {'R','E','O','L','E','_','%','u','\0'}; WINE_TRACE("(%p, %p)\n", This, lplpstg); - wsprintfW(name, template, olecallback.item_num++); + wsprintfW(name, L"REOLE_%u", olecallback.item_num++); return IStorage_CreateStorage(olecallback.stg, name, STGM_READWRITE | STGM_SHARE_EXCLUSIVE | STGM_CREATE, 0, 0, lplpstg); diff --git a/programs/wordpad/print.c b/programs/wordpad/print.c index d73c2d7757e..223111c86cb 100644 --- a/programs/wordpad/print.c +++ b/programs/wordpad/print.c @@ -50,27 +50,20 @@ static HGLOBAL devNames; static RECT margins; static previewinfo preview; -extern const WCHAR wszPreviewWndClass[]; - -static const WCHAR var_pagemargin[] = {'P','a','g','e','M','a','r','g','i','n',0}; -static const WCHAR var_previewpages[] = {'P','r','e','v','i','e','w','P','a','g','e','s',0}; - static LPWSTR get_print_file_filter(HWND hMainWnd) { static WCHAR wszPrintFilter[MAX_STRING_LEN*2+6+4+1]; - const WCHAR files_prn[] = {'*','.','P','R','N',0}; - const WCHAR files_all[] = {'*','.','*','\0'}; LPWSTR p; HINSTANCE hInstance = GetModuleHandleW(0); p = wszPrintFilter; LoadStringW(hInstance, STRING_PRINTER_FILES_PRN, p, MAX_STRING_LEN); p += lstrlenW(p) + 1; - lstrcpyW(p, files_prn); + lstrcpyW(p, L"*.PRN"); p += lstrlenW(p) + 1; LoadStringW(hInstance, STRING_ALL_FILES, p, MAX_STRING_LEN); p += lstrlenW(p) + 1; - lstrcpyW(p, files_all); + lstrcpyW(p, L"*.*"); p += lstrlenW(p) + 1; *p = 0; @@ -79,21 +72,21 @@ static LPWSTR get_print_file_filter(HWND hMainWnd) void registry_set_pagemargins(HKEY hKey) { - RegSetValueExW(hKey, var_pagemargin, 0, REG_BINARY, (LPBYTE)&margins, sizeof(RECT)); + RegSetValueExW(hKey, L"PageMargin", 0, REG_BINARY, (LPBYTE)&margins, sizeof(RECT)); } void registry_read_pagemargins(HKEY hKey) { DWORD size = sizeof(RECT); - if(!hKey || RegQueryValueExW(hKey, var_pagemargin, 0, NULL, (LPBYTE)&margins, + if(!hKey || RegQueryValueExW(hKey, L"PageMargin", 0, NULL, (LPBYTE)&margins, &size) != ERROR_SUCCESS || size != sizeof(RECT)) SetRect(&margins, 1757, 1417, 1757, 1417); } void registry_set_previewpages(HKEY hKey) { - RegSetValueExW(hKey, var_previewpages, 0, REG_DWORD, + RegSetValueExW(hKey, L"PreviewPages", 0, REG_DWORD, (LPBYTE)&preview.pages_shown, sizeof(DWORD)); } @@ -101,7 +94,7 @@ void registry_read_previewpages(HKEY hKey) { DWORD size = sizeof(DWORD); if(!hKey || - RegQueryValueExW(hKey, var_previewpages, 0, NULL, + RegQueryValueExW(hKey, L"PreviewPages", 0, NULL, (LPBYTE)&preview.pages_shown, &size) != ERROR_SUCCESS || size != sizeof(DWORD)) { @@ -238,8 +231,7 @@ void target_device(HWND hMainWnd, DWORD wordWrap) static LPWSTR dialog_print_to_file(HWND hMainWnd) { OPENFILENAMEW ofn; - static WCHAR file[MAX_PATH] = {'O','U','T','P','U','T','.','P','R','N',0}; - static const WCHAR defExt[] = {'P','R','N',0}; + static WCHAR file[MAX_PATH] = L"OUTPUT.PRN"; static LPWSTR file_filter; if(!file_filter) @@ -253,7 +245,7 @@ static LPWSTR dialog_print_to_file(HWND hMainWnd) ofn.lpstrFilter = file_filter; ofn.lpstrFile = file; ofn.nMaxFile = MAX_PATH; - ofn.lpstrDefExt = defExt; + ofn.lpstrDefExt = L"PRN"; if(GetSaveFileNameW(&ofn)) return file; @@ -305,7 +297,6 @@ static void add_ruler_units(HDC hdcRuler, RECT* drawRect, BOOL NewMetrics, LONG int CmPixels; int QuarterCmPixels; HFONT hFont; - WCHAR FontName[] = {'M','S',' ','S','a','n','s',' ','S','e','r','i','f',0}; if(hdc) { @@ -322,7 +313,7 @@ static void add_ruler_units(HDC hdcRuler, RECT* drawRect, BOOL NewMetrics, LONG SelectObject(hdc, hBitmap); FillRect(hdc, drawRect, GetStockObject(WHITE_BRUSH)); - hFont = CreateFontW(10, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, FontName); + hFont = CreateFontW(10, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, L"MS Sans Serif"); SelectObject(hdc, hFont); SetBkMode(hdc, TRANSPARENT); @@ -332,7 +323,6 @@ static void add_ruler_units(HDC hdcRuler, RECT* drawRect, BOOL NewMetrics, LONG for(i = 1, x = EditLeftmost; x < (drawRect->right - EditLeftmost + 1); i ++) { WCHAR str[3]; - WCHAR format[] = {'%','d',0}; int x2 = x; x2 += QuarterCmPixels; @@ -360,7 +350,7 @@ static void add_ruler_units(HDC hdcRuler, RECT* drawRect, BOOL NewMetrics, LONG if(x > RulerTextEnd) break; - wsprintfW(str, format, i); + wsprintfW(str, L"%d", i); TextOutW(hdc, x, 5, str, lstrlenW(str)); } DeleteObject(hFont); @@ -738,7 +728,7 @@ void init_preview(HWND hMainWnd, LPWSTR wszFileName) preview.zoomlevel = 0; preview_bar_show(hMainWnd, TRUE); - CreateWindowExW(0, wszPreviewWndClass, NULL, + CreateWindowExW(0, L"PrtPreview", NULL, WS_VISIBLE | WS_CHILD | WS_VSCROLL | WS_HSCROLL, 0, 0, 200, 10, hMainWnd, (HMENU)IDC_PREVIEW, hInstance, NULL); } @@ -898,13 +888,11 @@ static void update_preview_statusbar(HWND hMainWnd) p = wstr; if (preview.pages_shown < 2 || is_last_preview_page(preview.page)) { - static const WCHAR fmt[] = {' ','%','d','\0'}; p += LoadStringW(hInst, STRING_PREVIEW_PAGE, wstr, MAX_STRING_LEN); - wsprintfW(p, fmt, preview.page); + wsprintfW(p, L" %d", preview.page); } else { - static const WCHAR fmt[] = {' ','%','d','-','%','d','\0'}; p += LoadStringW(hInst, STRING_PREVIEW_PAGES, wstr, MAX_STRING_LEN); - wsprintfW(p, fmt, preview.page, preview.page + 1); + wsprintfW(p, L" %d-%d", preview.page, preview.page + 1); } SetWindowTextW(hStatusbar, wstr); } diff --git a/programs/wordpad/registry.c b/programs/wordpad/registry.c index 2de81c5d583..bb828f7562f 100644 --- a/programs/wordpad/registry.c +++ b/programs/wordpad/registry.c @@ -24,56 +24,27 @@ #include "wordpad.h" -static const WCHAR key_recentfiles[] = {'R','e','c','e','n','t',' ','f','i','l','e', - ' ','l','i','s','t',0}; -static const WCHAR key_options[] = {'O','p','t','i','o','n','s',0}; -static const WCHAR key_settings[] = {'S','e','t','t','i','n','g','s',0}; -static const WCHAR key_rtf[] = {'R','T','F',0}; -static const WCHAR key_text[] = {'T','e','x','t',0}; - -static const WCHAR var_file[] = {'F','i','l','e','%','d',0}; -static const WCHAR var_framerect[] = {'F','r','a','m','e','R','e','c','t',0}; -static const WCHAR var_barstate0[] = {'B','a','r','S','t','a','t','e','0',0}; -static const WCHAR var_wrap[] = {'W','r','a','p',0}; -static const WCHAR var_maximized[] = {'M','a','x','i','m','i','z','e','d',0}; - static LRESULT registry_get_handle(HKEY *hKey, LPDWORD action, LPCWSTR subKey) { LONG ret; - static const WCHAR wszProgramKey[] = {'S','o','f','t','w','a','r','e','\\', - 'M','i','c','r','o','s','o','f','t','\\', - 'W','i','n','d','o','w','s','\\', - 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\', - 'A','p','p','l','e','t','s','\\', - 'W','o','r','d','p','a','d',0}; - LPWSTR key = (LPWSTR)wszProgramKey; + LPWSTR key = calloc(lstrlenW(L"Software\\Microsoft\\Windows\\CurrentVersion\\Applets\\Wordpad\\")+lstrlenW(subKey)+1, sizeof(WCHAR)); - if(subKey) - { - WCHAR backslash[] = {'\\',0}; - key = calloc(lstrlenW(wszProgramKey)+lstrlenW(subKey)+lstrlenW(backslash)+1, sizeof(WCHAR)); + if(!key) return 1; - if(!key) - return 1; + lstrcpyW(key, L"Software\\Microsoft\\Windows\\CurrentVersion\\Applets\\Wordpad\\"); + lstrcatW(key, subKey); - lstrcpyW(key, wszProgramKey); - lstrcatW(key, backslash); - lstrcatW(key, subKey); - } + if(action) + { + ret = RegCreateKeyExW(HKEY_CURRENT_USER, key, 0, NULL, REG_OPTION_NON_VOLATILE, + KEY_READ | KEY_WRITE, NULL, hKey, action); + } else + { + ret = RegOpenKeyExW(HKEY_CURRENT_USER, key, 0, KEY_READ | KEY_WRITE, hKey); + } - if(action) - { - ret = RegCreateKeyExW(HKEY_CURRENT_USER, key, 0, NULL, REG_OPTION_NON_VOLATILE, - KEY_READ | KEY_WRITE, NULL, hKey, action); - } else - { - ret = RegOpenKeyExW(HKEY_CURRENT_USER, key, 0, KEY_READ | KEY_WRITE, hKey); - } - - if(subKey) - free(key); - - return ret; + free(key); + return ret; } void registry_set_options(HWND hMainWnd) @@ -81,7 +52,7 @@ void registry_set_options(HWND hMainWnd) HKEY hKey = 0; DWORD action; - if(registry_get_handle(&hKey, &action, key_options) == ERROR_SUCCESS) + if(registry_get_handle(&hKey, &action, L"Options") == ERROR_SUCCESS) { WINDOWPLACEMENT wp; DWORD isMaximized; @@ -90,14 +61,14 @@ void registry_set_options(HWND hMainWnd) GetWindowPlacement(hMainWnd, &wp); isMaximized = (wp.showCmd == SW_SHOWMAXIMIZED); - RegSetValueExW(hKey, var_framerect, 0, REG_BINARY, (LPBYTE)&wp.rcNormalPosition, sizeof(RECT)); - RegSetValueExW(hKey, var_maximized, 0, REG_DWORD, (LPBYTE)&isMaximized, sizeof(DWORD)); + RegSetValueExW(hKey, L"FrameRect", 0, REG_BINARY, (LPBYTE)&wp.rcNormalPosition, sizeof(RECT)); + RegSetValueExW(hKey, L"Maximized", 0, REG_DWORD, (LPBYTE)&isMaximized, sizeof(DWORD)); registry_set_pagemargins(hKey); RegCloseKey(hKey); } - if(registry_get_handle(&hKey, &action, key_settings) == ERROR_SUCCESS) + if(registry_get_handle(&hKey, &action, L"Settings") == ERROR_SUCCESS) { registry_set_previewpages(hKey); RegCloseKey(hKey); @@ -109,8 +80,8 @@ void registry_read_winrect(RECT* rc) HKEY hKey = 0; DWORD size = sizeof(RECT); - if(registry_get_handle(&hKey, 0, key_options) != ERROR_SUCCESS || - RegQueryValueExW(hKey, var_framerect, 0, NULL, (LPBYTE)rc, &size) != + if(registry_get_handle(&hKey, 0, L"Options") != ERROR_SUCCESS || + RegQueryValueExW(hKey, L"FrameRect", 0, NULL, (LPBYTE)rc, &size) != ERROR_SUCCESS || size != sizeof(RECT)) SetRect(rc, 0, 0, 600, 300); @@ -122,8 +93,8 @@ void registry_read_maximized(DWORD *bMaximized) HKEY hKey = 0; DWORD size = sizeof(DWORD); - if(registry_get_handle(&hKey, 0, key_options) != ERROR_SUCCESS || - RegQueryValueExW(hKey, var_maximized, 0, NULL, (LPBYTE)bMaximized, &size) != + if(registry_get_handle(&hKey, 0, L"Options") != ERROR_SUCCESS || + RegQueryValueExW(hKey, L"Maximized", 0, NULL, (LPBYTE)bMaximized, &size) != ERROR_SUCCESS || size != sizeof(DWORD)) { *bMaximized = FALSE; @@ -134,12 +105,10 @@ void registry_read_maximized(DWORD *bMaximized) static void truncate_path(LPWSTR file, LPWSTR out, LPWSTR pos1, LPWSTR pos2) { - static const WCHAR dots[] = {'.','.','.',0}; - *++pos1 = 0; lstrcatW(out, file); - lstrcatW(out, dots); + lstrcatW(out, L"..."); lstrcatW(out, pos2); } @@ -214,13 +183,12 @@ void registry_read_filelist(HWND hMainWnd) { HKEY hFileKey; - if(registry_get_handle(&hFileKey, 0, key_recentfiles) == ERROR_SUCCESS) + if(registry_get_handle(&hFileKey, 0, L"Recent file list") == ERROR_SUCCESS) { WCHAR itemText[MAX_PATH+3], buffer[MAX_PATH]; /* The menu item name is not the same as the file name, so we need to store the file name here */ static WCHAR file1[MAX_PATH], file2[MAX_PATH], file3[MAX_PATH], file4[MAX_PATH]; - WCHAR numFormat[] = {'&','%','d',' ',0}; LPWSTR pFile[] = {file1, file2, file3, file4}; DWORD pathSize = MAX_PATH*sizeof(WCHAR); int i; @@ -237,14 +205,14 @@ void registry_read_filelist(HWND hMainWnd) RemoveMenu(hMenu, ID_FILE_RECENT_SEPARATOR, MF_BYCOMMAND); for(i = 0; i < FILELIST_ENTRIES; i++) { - wsprintfW(key, var_file, i+1); + wsprintfW(key, L"File%d", i+1); RemoveMenu(hMenu, ID_FILE_RECENT1+i, MF_BYCOMMAND); if(RegQueryValueExW(hFileKey, (LPWSTR)key, 0, NULL, (LPBYTE)pFile[i], &pathSize) != ERROR_SUCCESS) break; mi.dwItemData = (ULONG_PTR)pFile[i]; - wsprintfW(itemText, numFormat, i+1); + wsprintfW(itemText, L"&%d ", i+1); lstrcpyW(buffer, pFile[i]); @@ -267,7 +235,7 @@ void registry_set_filelist(LPCWSTR newFile, HWND hMainWnd) HKEY hKey; DWORD action; - if(registry_get_handle(&hKey, &action, key_recentfiles) == ERROR_SUCCESS) + if(registry_get_handle(&hKey, &action, L"Recent file list") == ERROR_SUCCESS) { LPCWSTR pFiles[FILELIST_ENTRIES]; int i; @@ -313,7 +281,7 @@ void registry_set_filelist(LPCWSTR newFile, HWND hMainWnd) for(i = 0; i < FILELIST_ENTRIES && pFiles[i]; i++) { - wsprintfW(buffer, var_file, i+1); + wsprintfW(buffer, L"File%d", i+1); RegSetValueExW(hKey, (LPWSTR)&buffer, 0, REG_SZ, (const BYTE*)pFiles[i], (lstrlenW(pFiles[i])+1)*sizeof(WCHAR)); } @@ -332,7 +300,7 @@ void registry_read_options(void) { HKEY hKey; - if(registry_get_handle(&hKey, 0, key_options) != ERROR_SUCCESS) + if(registry_get_handle(&hKey, 0, L"Options") != ERROR_SUCCESS) registry_read_pagemargins(NULL); else { @@ -340,7 +308,7 @@ void registry_read_options(void) RegCloseKey(hKey); } - if(registry_get_handle(&hKey, 0, key_settings) != ERROR_SUCCESS) { + if(registry_get_handle(&hKey, 0, L"Settings") != ERROR_SUCCESS) { registry_read_previewpages(NULL); } else { registry_read_previewpages(hKey); @@ -363,7 +331,7 @@ static void registry_read_formatopts(int index, LPCWSTR key, DWORD barState[], D { DWORD size = sizeof(DWORD); - if(RegQueryValueExW(hKey, var_barstate0, 0, NULL, (LPBYTE)&barState[index], + if(RegQueryValueExW(hKey, L"BarState0", 0, NULL, (LPBYTE)&barState[index], &size) == ERROR_SUCCESS) fetched = TRUE; } @@ -375,7 +343,7 @@ static void registry_read_formatopts(int index, LPCWSTR key, DWORD barState[], D if(action == REG_OPENED_EXISTING_KEY) { DWORD size = sizeof(DWORD); - if(RegQueryValueExW(hKey, var_wrap, 0, NULL, (LPBYTE)&wordWrap[index], + if(RegQueryValueExW(hKey, L"Wrap", 0, NULL, (LPBYTE)&wordWrap[index], &size) == ERROR_SUCCESS) fetched = TRUE; } @@ -393,8 +361,8 @@ static void registry_read_formatopts(int index, LPCWSTR key, DWORD barState[], D void registry_read_formatopts_all(DWORD barState[], DWORD wordWrap[]) { - registry_read_formatopts(reg_formatindex(SF_RTF), key_rtf, barState, wordWrap); - registry_read_formatopts(reg_formatindex(SF_TEXT), key_text, barState, wordWrap); + registry_read_formatopts(reg_formatindex(SF_RTF), L"RTF", barState, wordWrap); + registry_read_formatopts(reg_formatindex(SF_TEXT), L"Text", barState, wordWrap); } static void registry_set_formatopts(int index, LPCWSTR key, DWORD barState[], DWORD wordWrap[]) @@ -404,9 +372,9 @@ static void registry_set_formatopts(int index, LPCWSTR key, DWORD barState[], DW if(registry_get_handle(&hKey, &action, key) == ERROR_SUCCESS) { - RegSetValueExW(hKey, var_barstate0, 0, REG_DWORD, (LPBYTE)&barState[index], + RegSetValueExW(hKey, L"BarState0", 0, REG_DWORD, (LPBYTE)&barState[index], sizeof(DWORD)); - RegSetValueExW(hKey, var_wrap, 0, REG_DWORD, (LPBYTE)&wordWrap[index], + RegSetValueExW(hKey, L"Wrap", 0, REG_DWORD, (LPBYTE)&wordWrap[index], sizeof(DWORD)); RegCloseKey(hKey); } @@ -414,6 +382,6 @@ static void registry_set_formatopts(int index, LPCWSTR key, DWORD barState[], DW void registry_set_formatopts_all(DWORD barState[], DWORD wordWrap[]) { - registry_set_formatopts(reg_formatindex(SF_RTF), key_rtf, barState, wordWrap); - registry_set_formatopts(reg_formatindex(SF_TEXT), key_text, barState, wordWrap); + registry_set_formatopts(reg_formatindex(SF_RTF), L"RTF", barState, wordWrap); + registry_set_formatopts(reg_formatindex(SF_TEXT), L"Text", barState, wordWrap); } diff --git a/programs/wordpad/wordpad.c b/programs/wordpad/wordpad.c index b357ef7d6b8..8617c2477c1 100644 --- a/programs/wordpad/wordpad.c +++ b/programs/wordpad/wordpad.c @@ -38,13 +38,6 @@ #include "wordpad.h" /* use LoadString */ -static const WCHAR wszAppTitle[] = {'W','i','n','e',' ','W','o','r','d','p','a','d',0}; - -static const WCHAR wszMainWndClass[] = {'W','O','R','D','P','A','D','T','O','P',0}; - -static const WCHAR stringFormat[] = {'%','2','d','\0'}; - -const WCHAR wszPreviewWndClass[] = {'P','r','t','P','r','e','v','i','e','w',0}; LRESULT CALLBACK preview_proc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); static HWND hMainWnd; @@ -89,23 +82,20 @@ typedef struct static void DoLoadStrings(void) { LPWSTR p = wszFilter; - static const WCHAR files_rtf[] = {'*','.','r','t','f','\0'}; - static const WCHAR files_txt[] = {'*','.','t','x','t','\0'}; - static const WCHAR files_all[] = {'*','.','*','\0'}; HINSTANCE hInstance = GetModuleHandleW(0); p += 1 + LoadStringW(hInstance, STRING_RICHTEXT_FILES_RTF, p, MAX_STRING_LEN); - lstrcpyW(p, files_rtf); + lstrcpyW(p, L"*.rtf"); p += lstrlenW(p) + 1; p += 1 + LoadStringW(hInstance, STRING_TEXT_FILES_TXT, p, MAX_STRING_LEN); - lstrcpyW(p, files_txt); + lstrcpyW(p, L"*.txt"); p += lstrlenW(p) + 1; p += 1 + LoadStringW(hInstance, STRING_TEXT_FILES_UNICODE_TXT, p, MAX_STRING_LEN); - lstrcpyW(p, files_txt); + lstrcpyW(p, L"*.txt"); p += lstrlenW(p) + 1; p += 1 + LoadStringW(hInstance, STRING_ALL_FILES, p, MAX_STRING_LEN); - lstrcpyW(p, files_all); + lstrcpyW(p, L"*.*"); p += lstrlenW(p) + 1; *p = '\0'; @@ -220,25 +210,20 @@ LPWSTR file_basename(LPWSTR path) static void set_caption(LPCWSTR wszNewFileName) { - static const WCHAR wszSeparator[] = {' ','-',' '}; WCHAR *wszCaption; - SIZE_T length = 0; if(!wszNewFileName) wszNewFileName = wszDefaultFileName; else wszNewFileName = file_basename((LPWSTR)wszNewFileName); - wszCaption = calloc(1, lstrlenW(wszNewFileName)*sizeof(WCHAR)+sizeof(wszSeparator)+sizeof(wszAppTitle)); + wszCaption = calloc(1, lstrlenW(wszNewFileName)*sizeof(WCHAR)+sizeof(L" - Wine Wordpad")); if(!wszCaption) return; memcpy(wszCaption, wszNewFileName, lstrlenW(wszNewFileName)*sizeof(WCHAR)); - length += lstrlenW(wszNewFileName); - memcpy(wszCaption + length, wszSeparator, sizeof(wszSeparator)); - length += ARRAY_SIZE(wszSeparator); - memcpy(wszCaption + length, wszAppTitle, sizeof(wszAppTitle)); + wcscat(wszCaption, L" - Wine Wordpad"); SetWindowTextW(hMainWnd, wszCaption); @@ -325,7 +310,7 @@ static void on_sizelist_modified(HWND hwndSizeList, LPWSTR wszNewFontSize) format.cbSize = sizeof(format); SendMessageW(hEditorWnd, EM_GETCHARFORMAT, SCF_SELECTION, (LPARAM)&format); - wsprintfW(sizeBuffer, stringFormat, format.yHeight / 20); + wsprintfW(sizeBuffer, L"%2d", format.yHeight / 20); if(lstrcmpW(sizeBuffer, wszNewFontSize)) { float size = 0; @@ -337,7 +322,7 @@ static void on_sizelist_modified(HWND hwndSizeList, LPWSTR wszNewFontSize) { SetWindowTextW(hwndSizeList, sizeBuffer); MessageBoxWithResStringW(hMainWnd, MAKEINTRESOURCEW(STRING_INVALID_NUMBER), - wszAppTitle, MB_OK | MB_ICONINFORMATION); + L"Wine Wordpad", MB_OK | MB_ICONINFORMATION); } } } @@ -349,7 +334,7 @@ static void add_size(HWND hSizeListWnd, unsigned size) cbItem.mask = CBEIF_TEXT; cbItem.iItem = -1; - wsprintfW(buffer, stringFormat, size); + wsprintfW(buffer, L"%2d", size); cbItem.pszText = buffer; SendMessageW(hSizeListWnd, CBEM_INSERTITEMW, 0, (LPARAM)&cbItem); } @@ -389,7 +374,7 @@ static void populate_size_list(HWND hSizeListWnd) add_size(hSizeListWnd, choices[i]); } - wsprintfW(buffer, stringFormat, fmt.yHeight / 20); + wsprintfW(buffer, L"%2d", fmt.yHeight / 20); SendMessageW(hListEditWnd, WM_SETTEXT, 0, (LPARAM)buffer); } @@ -407,7 +392,7 @@ static void update_size_list(void) SendMessageW(hEditorWnd, EM_GETCHARFORMAT, SCF_SELECTION, (LPARAM)&fmt); SendMessageW(hwndSizeListEdit, WM_GETTEXT, MAX_PATH, (LPARAM)fontSize); - wsprintfW(sizeBuffer, stringFormat, fmt.yHeight / 20); + wsprintfW(sizeBuffer, L"%2d", fmt.yHeight / 20); if(lstrcmpW(fontSize, sizeBuffer)) SendMessageW(hwndSizeListEdit, WM_SETTEXT, 0, (LPARAM)sizeBuffer); @@ -492,9 +477,6 @@ static void set_font(LPCWSTR wszFaceName) static void set_default_font(void) { - static const WCHAR richTextFont[] = {'T','i','m','e','s',' ','N','e','w',' ', - 'R','o','m','a','n',0}; - static const WCHAR plainTextFont[] = {'C','o','u','r','i','e','r',' ','N','e','w',0}; CHARFORMAT2W fmt; LPCWSTR font; @@ -505,9 +487,9 @@ static void set_default_font(void) fmt.dwEffects = 0; if(fileFormat & SF_RTF) - font = richTextFont; + font = L"Times New Roman"; else - font = plainTextFont; + font = L"Courier New"; lstrcpyW(fmt.szFaceName, font); @@ -815,7 +797,7 @@ static void ShowOpenError(DWORD Code) default: Message = MAKEINTRESOURCEW(STRING_OPEN_FAILED); } - MessageBoxW(hMainWnd, Message, wszAppTitle, MB_ICONEXCLAMATION | MB_OK); + MessageBoxW(hMainWnd, Message, L"Wine Wordpad", MB_ICONEXCLAMATION | MB_OK); } static void DoOpenFile(LPCWSTR szOpenFileName) @@ -852,7 +834,7 @@ static void DoOpenFile(LPCWSTR szOpenFileName) { CloseHandle(hFile); MessageBoxWithResStringW(hMainWnd, MAKEINTRESOURCEW(STRING_OLE_STORAGE_NOT_SUPPORTED), - wszAppTitle, MB_OK | MB_ICONEXCLAMATION); + L"Wine Wordpad", MB_OK | MB_ICONEXCLAMATION); return; } } @@ -889,7 +871,7 @@ static void ShowWriteError(DWORD Code) default: Message = MAKEINTRESOURCEW(STRING_WRITE_FAILED); } - MessageBoxW(hMainWnd, Message, wszAppTitle, MB_ICONEXCLAMATION | MB_OK); + MessageBoxW(hMainWnd, Message, L"Wine Wordpad", MB_ICONEXCLAMATION | MB_OK); } static BOOL DoSaveFile(LPCWSTR wszSaveFileName, WPARAM format) @@ -952,7 +934,6 @@ static BOOL DialogSaveFile(void) OPENFILENAMEW sfn; WCHAR wszFile[MAX_PATH] = {'\0'}; - static const WCHAR wszDefExt[] = {'r','t','f','\0'}; ZeroMemory(&sfn, sizeof(sfn)); @@ -962,7 +943,7 @@ static BOOL DialogSaveFile(void) sfn.lpstrFilter = wszFilter; sfn.lpstrFile = wszFile; sfn.nMaxFile = MAX_PATH; - sfn.lpstrDefExt = wszDefExt; + sfn.lpstrDefExt = L"rtf"; sfn.nFilterIndex = fileformat_number(fileFormat)+1; while(GetSaveFileNameW(&sfn)) @@ -970,7 +951,7 @@ static BOOL DialogSaveFile(void) if(fileformat_flags(sfn.nFilterIndex-1) != SF_RTF) { if(MessageBoxWithResStringW(hMainWnd, MAKEINTRESOURCEW(STRING_SAVE_LOSEFORMATTING), - wszAppTitle, MB_YESNO | MB_ICONEXCLAMATION) != IDYES) + L"Wine Wordpad", MB_YESNO | MB_ICONEXCLAMATION) != IDYES) continue; } return DoSaveFile(sfn.lpstrFile, fileformat_flags(sfn.nFilterIndex-1)); @@ -1010,7 +991,7 @@ static BOOL prompt_save_changes(void) wsprintfW(text, wszSaveChanges, displayFileName); - ret = MessageBoxW(hMainWnd, text, wszAppTitle, MB_YESNOCANCEL | MB_ICONEXCLAMATION); + ret = MessageBoxW(hMainWnd, text, L"Wine Wordpad", MB_YESNOCANCEL | MB_ICONEXCLAMATION); free(text); @@ -1035,7 +1016,6 @@ static void DialogOpenFile(void) OPENFILENAMEW ofn; WCHAR wszFile[MAX_PATH] = {'\0'}; - static const WCHAR wszDefExt[] = {'r','t','f','\0'}; ZeroMemory(&ofn, sizeof(ofn)); @@ -1045,7 +1025,7 @@ static void DialogOpenFile(void) ofn.lpstrFilter = wszFilter; ofn.lpstrFile = wszFile; ofn.nMaxFile = MAX_PATH; - ofn.lpstrDefExt = wszDefExt; + ofn.lpstrDefExt = L"rtf"; ofn.nFilterIndex = fileformat_number(fileFormat)+1; if(GetOpenFileNameW(&ofn)) @@ -1058,7 +1038,7 @@ static void DialogOpenFile(void) static void dialog_about(void) { HICON icon = LoadImageW(GetModuleHandleW(0), MAKEINTRESOURCEW(IDI_WORDPAD), IMAGE_ICON, 48, 48, LR_SHARED); - ShellAboutW(hMainWnd, wszAppTitle, 0, icon); + ShellAboutW(hMainWnd, L"Wine Wordpad", 0, icon); } static INT_PTR CALLBACK formatopts_proc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) @@ -1255,7 +1235,7 @@ static void HandleCommandLine(LPWSTR cmdline) } if (opt_print) - MessageBoxWithResStringW(hMainWnd, MAKEINTRESOURCEW(STRING_PRINTING_NOT_IMPLEMENTED), wszAppTitle, MB_OK); + MessageBoxWithResStringW(hMainWnd, MAKEINTRESOURCEW(STRING_PRINTING_NOT_IMPLEMENTED), L"Wine Wordpad", MB_OK); } static LRESULT handle_findmsg(LPFINDREPLACEW pFr) @@ -1337,7 +1317,7 @@ static LRESULT handle_findmsg(LPFINDREPLACEW pFr) custom_data->endPos = -1; EnableWindow(hMainWnd, FALSE); MessageBoxWithResStringW(hFindWnd, MAKEINTRESOURCEW(STRING_SEARCH_FINISHED), - wszAppTitle, MB_OK | MB_ICONASTERISK | MB_TASKMODAL); + L"Wine Wordpad", MB_OK | MB_ICONASTERISK | MB_TASKMODAL); EnableWindow(hMainWnd, TRUE); } else { SendMessageW(hEditorWnd, EM_SETSEL, ft.chrgText.cpMin, ft.chrgText.cpMax); @@ -1356,7 +1336,6 @@ static void dialog_find(LPFINDREPLACEW fr, BOOL replace) static WCHAR selBuffer[128]; static WCHAR replaceBuffer[128]; static FINDREPLACE_custom custom_data; - static const WCHAR endl = '\r'; FINDTEXTW ft; /* Allow only one search/replace dialog to open */ @@ -1375,7 +1354,7 @@ static void dialog_find(LPFINDREPLACEW fr, BOOL replace) * find field is used. */ SendMessageW(hEditorWnd, EM_GETSEL, (WPARAM)&ft.chrg.cpMin, (LPARAM)&ft.chrg.cpMax); - ft.lpstrText = &endl; + ft.lpstrText = L"\r"; if (ft.chrg.cpMin != ft.chrg.cpMax && SendMessageW(hEditorWnd, EM_FINDTEXTW, FR_DOWN, (LPARAM)&ft) == -1) { @@ -1424,17 +1403,15 @@ static int units_to_twips(UNIT unit, float number) static void append_current_units(LPWSTR buffer) { - static const WCHAR space[] = {' ', 0}; - lstrcatW(buffer, space); + lstrcatW(buffer, L" "); lstrcatW(buffer, units_cmW); } static void number_with_units(LPWSTR buffer, int number) { - static const WCHAR fmt[] = {'%','.','2','f',' ','%','s','\0'}; float converted = (float)number / (float)TWIPS_PER_INCH *(float)CENTMM_PER_INCH / 1000.0; - swprintf(buffer, MAX_STRING_LEN, fmt, converted, units_cmW); + swprintf(buffer, MAX_STRING_LEN, L"%.2f %s", converted, units_cmW); } static BOOL get_comboexlist_selection(HWND hComboEx, LPWSTR wszBuffer, UINT bufferLength) @@ -1655,7 +1632,7 @@ static INT_PTR CALLBACK paraformat_proc(HWND hWnd, UINT message, WPARAM wParam, if(ret != 3) { MessageBoxWithResStringW(hMainWnd, MAKEINTRESOURCEW(STRING_INVALID_NUMBER), - wszAppTitle, MB_OK | MB_ICONASTERISK); + L"Wine Wordpad", MB_OK | MB_ICONASTERISK); return FALSE; } else { @@ -1775,10 +1752,10 @@ static INT_PTR CALLBACK tabstops_proc(HWND hWnd, UINT message, WPARAM wParam, LP if(!number_from_string(buffer, &number, &unit)) { MessageBoxWithResStringW(hWnd, MAKEINTRESOURCEW(STRING_INVALID_NUMBER), - wszAppTitle, MB_OK | MB_ICONINFORMATION); + L"Wine Wordpad", MB_OK | MB_ICONINFORMATION); } else if (item_count >= MAX_TAB_STOPS) { MessageBoxWithResStringW(hWnd, MAKEINTRESOURCEW(STRING_MAX_TAB_STOPS), - wszAppTitle, MB_OK | MB_ICONINFORMATION); + L"Wine Wordpad", MB_OK | MB_ICONINFORMATION); } else { int i; float next_number = -1; @@ -1869,12 +1846,8 @@ static LRESULT OnCreate( HWND hWnd ) HDC hdc; SIZE name_sz, size_sz; int height, dpi; - static const WCHAR wszRichEditDll[] = {'R','I','C','H','E','D','2','0','.','D','L','L','\0'}; - static const WCHAR wszRichEditText[] = {'R','i','c','h','E','d','i','t',' ','t','e','x','t','\0'}; - static const WCHAR font_text[] = {'T','i','m','e','s',' ','N','e','w',' ','R','o','m','a','n',0}; /* a long font name */ - static const WCHAR size_text[] = {' ','0','0',0}; /* enough for two digits */ - CreateStatusWindowW(CCS_NODIVIDER|WS_CHILD|WS_VISIBLE, wszRichEditText, hWnd, IDC_STATUSBAR); + CreateStatusWindowW(CCS_NODIVIDER|WS_CHILD|WS_VISIBLE, L"RichEdit text", hWnd, IDC_STATUSBAR); hReBarWnd = CreateWindowExW(WS_EX_TOOLWINDOW, REBARCLASSNAMEW, NULL, CCS_NODIVIDER|WS_CHILD|WS_VISIBLE|WS_CLIPSIBLINGS|WS_CLIPCHILDREN|RBS_VARHEIGHT|CCS_TOP, @@ -1942,8 +1915,8 @@ static LRESULT OnCreate( HWND hWnd ) font = (HFONT)SendMessageW(hFontListWnd, WM_GETFONT, 0, 0); hdc = GetDC(hFontListWnd); font = SelectObject(hdc, font); - GetTextExtentPointW(hdc, font_text, ARRAY_SIZE(font_text) - 1, &name_sz); - GetTextExtentPointW(hdc, size_text, ARRAY_SIZE(size_text) - 1, &size_sz); + GetTextExtentPointW(hdc, L"Times New Roman", ARRAY_SIZE(L"Times New Roman") - 1, &name_sz); + GetTextExtentPointW(hdc, L" 00", ARRAY_SIZE(L" 00") - 1, &size_sz); font = SelectObject(hdc, font); ReleaseDC(hFontListWnd, hdc); rbb.hwndChild = hFontListWnd; @@ -1998,10 +1971,10 @@ static LRESULT OnCreate( HWND hWnd ) SendMessageW(hReBarWnd, RB_INSERTBANDW, -1, (LPARAM)&rbb); - hDLL = LoadLibraryW(wszRichEditDll); + hDLL = LoadLibraryW(L"riched20.dll"); if(!hDLL) { - MessageBoxWithResStringW(hWnd, MAKEINTRESOURCEW(STRING_LOAD_RICHED_FAILED), wszAppTitle, + MessageBoxWithResStringW(hWnd, MAKEINTRESOURCEW(STRING_LOAD_RICHED_FAILED), L"Wine Wordpad", MB_OK | MB_ICONEXCLAMATION); PostQuitMessage(1); } @@ -2390,7 +2363,7 @@ static LRESULT OnCommand( HWND hWnd, WPARAM wParam, LPARAM lParam) TEXTRANGEW tr; GetWindowTextW(hwndEditor, data, nLen+1); - MessageBoxW(NULL, data, wszAppTitle, MB_OK); + MessageBoxW(NULL, data, L"Wine Wordpad", MB_OK); free(data); data = malloc((nLen+1)*sizeof(WCHAR)); @@ -2398,7 +2371,7 @@ static LRESULT OnCommand( HWND hWnd, WPARAM wParam, LPARAM lParam) tr.chrg.cpMax = nLen; tr.lpstrText = data; SendMessageW(hwndEditor, EM_GETTEXTRANGE, 0, (LPARAM)&tr); - MessageBoxW(NULL, data, wszAppTitle, MB_OK); + MessageBoxW(NULL, data, L"Wine Wordpad", MB_OK); free(data); /* SendMessage(hwndEditor, EM_SETSEL, 0, -1); */ @@ -2438,7 +2411,7 @@ static LRESULT OnCommand( HWND hWnd, WPARAM wParam, LPARAM lParam) SendMessageW(hwndEditor, EM_GETSELTEXT, 0, (LPARAM)data); sprintf(buf, "Start = %ld, End = %ld", range.cpMin, range.cpMax); MessageBoxA(hWnd, buf, "Editor", MB_OK); - MessageBoxW(hWnd, data, wszAppTitle, MB_OK); + MessageBoxW(hWnd, data, L"Wine Wordpad", MB_OK); free(data); /* SendMessage(hwndEditor, EM_SETSEL, 0, -1); */ return 0; @@ -2804,12 +2777,10 @@ int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hOldInstance, LPSTR szCmdPar MONITORINFO info; HMONITOR monitor; int x, y; - static const WCHAR wszAccelTable[] = {'M','A','I','N','A','C','C','E','L', - 'T','A','B','L','E','\0'}; InitCommonControlsEx(&classes); - hAccel = LoadAcceleratorsW(hInstance, wszAccelTable); + hAccel = LoadAcceleratorsW(hInstance, L"MAINACCELTABLE"); wc.cbSize = sizeof(wc); wc.style = 0; @@ -2823,7 +2794,7 @@ int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hOldInstance, LPSTR szCmdPar wc.hCursor = LoadCursorW(NULL, (LPWSTR)IDC_IBEAM); wc.hbrBackground = GetSysColorBrush(COLOR_WINDOW); wc.lpszMenuName = MAKEINTRESOURCEW(IDM_MAINMENU); - wc.lpszClassName = wszMainWndClass; + wc.lpszClassName = L"WORDPADTOP"; RegisterClassExW(&wc); wc.style = 0; @@ -2836,7 +2807,7 @@ int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hOldInstance, LPSTR szCmdPar wc.hCursor = LoadCursorW(NULL, (LPWSTR)IDC_IBEAM); wc.hbrBackground = NULL; wc.lpszMenuName = NULL; - wc.lpszClassName = wszPreviewWndClass; + wc.lpszClassName = L"PrtPreview"; RegisterClassExW(&wc); registry_read_winrect(&rc); @@ -2850,7 +2821,7 @@ int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hOldInstance, LPSTR szCmdPar if (IsRectEmpty(&info.rcWork)) x = y = CW_USEDEFAULT; - hMainWnd = CreateWindowExW(0, wszMainWndClass, wszAppTitle, WS_CLIPCHILDREN|WS_OVERLAPPEDWINDOW, + hMainWnd = CreateWindowExW(0, L"WORDPADTOP", L"Wine Wordpad", WS_CLIPCHILDREN|WS_OVERLAPPEDWINDOW, x, y, rc.right - rc.left, rc.bottom - rc.top, NULL, NULL, hInstance, NULL); registry_read_maximized(&bMaximized); if ((nCmdShow == SW_SHOWNORMAL || nCmdShow == SW_SHOWDEFAULT)