From e0db930d647cb9ab07a772574e2a8d4c2daa72b1 Mon Sep 17 00:00:00 2001 From: Ged Murphy Date: Tue, 2 May 2006 21:01:43 +0000 Subject: [PATCH] - convert the screensaver to tchar and build as unicode. - gets around the ANSI bug in the config dialog svn path=/trunk/; revision=21776 --- .../applications/screensavers/matrix/config.c | 5 +- .../screensavers/matrix/globals.h | 6 +- .../applications/screensavers/matrix/matrix.c | 1 + .../screensavers/matrix/matrix.rbuild | 2 + .../screensavers/matrix/message.c | 4 +- .../screensavers/matrix/message.h | 2 +- .../screensavers/matrix/password.c | 9 +-- .../screensavers/matrix/screensave.c | 13 ++-- .../screensavers/matrix/settings.c | 63 ++++++++++--------- 9 files changed, 56 insertions(+), 49 deletions(-) diff --git a/reactos/base/applications/screensavers/matrix/config.c b/reactos/base/applications/screensavers/matrix/config.c index a8c833c7daa..8b9523cbeaa 100644 --- a/reactos/base/applications/screensavers/matrix/config.c +++ b/reactos/base/applications/screensavers/matrix/config.c @@ -5,6 +5,7 @@ // #include #include +#include #include "resource.h" #include "globals.h" #include "message.h" @@ -32,7 +33,7 @@ void AddFonts(HWND hwndCombo) lf.lfCharSet = ANSI_CHARSET; lf.lfPitchAndFamily = 0; - lf.lfFaceName[0] = '\0'; + lf.lfFaceName[0] = _T('\0'); hdc = GetDC(0); EnumFontFamiliesEx(hdc, &lf, (FONTENUMPROC)EnumFontProc, (LONG)hwndCombo, 0); @@ -54,7 +55,7 @@ void UpdatePreview(HWND hwnd) // BOOL CALLBACK ConfigDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { - static char buf[256]; + static TCHAR buf[256]; HWND hwndCombo, hwndCtrl; int index, items, val; RECT rect; diff --git a/reactos/base/applications/screensavers/matrix/globals.h b/reactos/base/applications/screensavers/matrix/globals.h index 857b18617fd..4e5522428ad 100644 --- a/reactos/base/applications/screensavers/matrix/globals.h +++ b/reactos/base/applications/screensavers/matrix/globals.h @@ -5,7 +5,7 @@ extern "C" { #endif -#define APPNAME "MATRIX ScreenSaver 2.0" +#define APPNAME _T("MATRIX ScreenSaver 2.0") #define DENSITY 24 #define DENSITY_MAX 50 @@ -32,9 +32,9 @@ extern "C" { #define FONT_MIN 8 #define FONT_MAX 30 -extern char g_szMessages[MAX_MESSAGES][MAXMSG_LENGTH]; +extern TCHAR g_szMessages[MAX_MESSAGES][MAXMSG_LENGTH]; extern int g_nFontSize; -extern char g_szFontName[]; +extern TCHAR g_szFontName[]; extern BOOL g_fFontBold; extern int g_nNumMessages; extern int g_nCurrentMessage; diff --git a/reactos/base/applications/screensavers/matrix/matrix.c b/reactos/base/applications/screensavers/matrix/matrix.c index 56685a9dfa4..dd439eb3393 100644 --- a/reactos/base/applications/screensavers/matrix/matrix.c +++ b/reactos/base/applications/screensavers/matrix/matrix.c @@ -5,6 +5,7 @@ // #include #include +#include #include "globals.h" #include "message.h" #include "matrix.h" diff --git a/reactos/base/applications/screensavers/matrix/matrix.rbuild b/reactos/base/applications/screensavers/matrix/matrix.rbuild index e0bd98fe51a..4ea82b57f16 100644 --- a/reactos/base/applications/screensavers/matrix/matrix.rbuild +++ b/reactos/base/applications/screensavers/matrix/matrix.rbuild @@ -8,6 +8,8 @@ 0x0501 0x0501 + + kernel32 user32 diff --git a/reactos/base/applications/screensavers/matrix/message.c b/reactos/base/applications/screensavers/matrix/message.c index 7c33e7ce16b..d5e17c07df9 100644 --- a/reactos/base/applications/screensavers/matrix/message.c +++ b/reactos/base/applications/screensavers/matrix/message.c @@ -35,7 +35,7 @@ WORD crc_msgrand(WORD reg) // // Set a new message based on font and text // -void SetMatrixMessage(MATRIX_MESSAGE *msg, HFONT hFont, char *text) +void SetMatrixMessage(MATRIX_MESSAGE *msg, HFONT hFont, TCHAR *text) { HDC hdc; RECT rect; @@ -198,7 +198,7 @@ void DoMatrixMessage(HDC hdc, MATRIX *matrix) // // Set current font used for messages // -void SetMessageFont(HWND hwnd, char *szFontName, int nPointSize, BOOL fBold) +void SetMessageFont(HWND hwnd, TCHAR *szFontName, int nPointSize, BOOL fBold) { int lfHeight; HDC hdc; diff --git a/reactos/base/applications/screensavers/matrix/message.h b/reactos/base/applications/screensavers/matrix/message.h index 6f62b25c07b..7a751a8f2bc 100644 --- a/reactos/base/applications/screensavers/matrix/message.h +++ b/reactos/base/applications/screensavers/matrix/message.h @@ -22,7 +22,7 @@ typedef struct } MATRIX_MESSAGE; -void SetMessageFont(HWND hwnd, char *szFontName, int nPointSize, BOOL fBold); +void SetMessageFont(HWND hwnd, TCHAR *szFontName, int nPointSize, BOOL fBold); MATRIX_MESSAGE *InitMatrixMessage(HWND hwnd, int width, int height); #ifdef __cplusplus diff --git a/reactos/base/applications/screensavers/matrix/password.c b/reactos/base/applications/screensavers/matrix/password.c index 719ed2663d9..6fc5e2bf803 100644 --- a/reactos/base/applications/screensavers/matrix/password.c +++ b/reactos/base/applications/screensavers/matrix/password.c @@ -4,9 +4,10 @@ // Password support for Win9x // #include +#include typedef BOOL (WINAPI *VERIFYSCREENSAVEPWD)(HWND hwnd); -typedef VOID (WINAPI *PWDCHANGEPASSWORD)(LPCSTR lpcRegkeyname, HWND hwnd,UINT uiReserved1,UINT uiReserved2); +typedef VOID (WINAPI *PWDCHANGEPASSWORD)(LPCTSTR lpcRegkeyname, HWND hwnd,UINT uiReserved1,UINT uiReserved2); BOOL VerifyPassword(HWND hwnd) { @@ -22,7 +23,7 @@ BOOL VerifyPassword(HWND hwnd) if(GetVersion() < 0x80000000) return TRUE; - hpwdcpl = LoadLibrary("PASSWORD.CPL"); + hpwdcpl = LoadLibrary(_T("PASSWORD.CPL")); if(hpwdcpl == NULL) { @@ -47,7 +48,7 @@ BOOL VerifyPassword(HWND hwnd) BOOL ChangePassword(HWND hwnd) { // This only ever gets called under '95, when started with the /a option. - HINSTANCE hmpr = LoadLibrary("MPR.DLL"); + HINSTANCE hmpr = LoadLibrary(_T("MPR.DLL")); PWDCHANGEPASSWORD PwdChangePassword; if(hmpr == NULL) @@ -61,7 +62,7 @@ BOOL ChangePassword(HWND hwnd) return FALSE; } - PwdChangePassword("SCRSAVE", hwnd, 0, 0); + PwdChangePassword(_T("SCRSAVE"), hwnd, 0, 0); FreeLibrary(hmpr); return TRUE; diff --git a/reactos/base/applications/screensavers/matrix/screensave.c b/reactos/base/applications/screensavers/matrix/screensave.c index 8bceafcb880..b58c9e2a16c 100644 --- a/reactos/base/applications/screensavers/matrix/screensave.c +++ b/reactos/base/applications/screensavers/matrix/screensave.c @@ -11,6 +11,7 @@ // #include #include +#include #include "globals.h" #include "message.h" #include "matrix.h" @@ -58,7 +59,7 @@ BOOL ScreenSaver(HWND hwndParent) SystemParametersInfo(SPI_SETSCREENSAVERRUNNING, TRUE, &nPreviousState, 0); // Dynamically locate API call from USER32 - not present in all versions - hUser32 = GetModuleHandle("USER32.DLL"); + hUser32 = GetModuleHandle(_T("USER32.DLL")); pfnEnumDisplayMonitors = (PVOID)GetProcAddress(hUser32, "EnumDisplayMonitors"); // If we're running Win2k+ then the API is available...so call it! @@ -99,7 +100,7 @@ BOOL ScreenSaver(HWND hwndParent) // -p (preview) // -c (configure) // -BOOL ParseCommandLine(PSTR szCmdLine, int *chOption, HWND *hwndParent) +BOOL ParseCommandLine(LPSTR szCmdLine, int *chOption, HWND *hwndParent) { int ch = *szCmdLine++; @@ -150,10 +151,10 @@ int WINAPI WinMain (HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpCmdLine, int iCmdS switch(chOption) { - case 's': return ScreenSaver(NULL); // screen save - case 'p': return ScreenSaver(hwndParent); // preview in small window - case 'a': return ChangePassword(hwndParent); // ask for password - case 'c': return Configure(hwndParent); // configuration dialog + case _T('s'): return ScreenSaver(NULL); // screen save + case _T('p'): return ScreenSaver(hwndParent); // preview in small window + case _T('a'): return ChangePassword(hwndParent); // ask for password + case _T('c'): return Configure(hwndParent); // configuration dialog default: return Configure(hwndParent); // configuration dialog } diff --git a/reactos/base/applications/screensavers/matrix/settings.c b/reactos/base/applications/screensavers/matrix/settings.c index a274263e43f..49b2f54b976 100644 --- a/reactos/base/applications/screensavers/matrix/settings.c +++ b/reactos/base/applications/screensavers/matrix/settings.c @@ -4,14 +4,15 @@ // Load/Save settings from registry // #include +#include #include "globals.h" #include "message.h" #include "matrix.h" -char g_szMessages[MAX_MESSAGES][MAXMSG_LENGTH]; +TCHAR g_szMessages[MAX_MESSAGES][MAXMSG_LENGTH]; int g_nNumMessages = 0; int g_nMessageSpeed = 5; -char g_szFontName[512] = "Arial"; +TCHAR g_szFontName[512] = _T("Arial"); int g_nMatrixSpeed = 150; int g_nDensity = 32; @@ -27,61 +28,61 @@ void LoadSettings() HKEY hkey; LONG value; ULONG len; - char *hugechar = malloc(4096); - char *hptr = hugechar; + TCHAR *hugechar = malloc(4096); + TCHAR *hptr = hugechar; if(hugechar == 0) return; - hugechar[0] = '\0'; + hugechar[0] = _T('\0'); - RegCreateKeyEx(HKEY_CURRENT_USER, "Software\\Catch22\\Matrix Screen Saver", 0, - "", 0, KEY_READ, NULL, &hkey, NULL); + RegCreateKeyEx(HKEY_CURRENT_USER, _T("Software\\Catch22\\Matrix Screen Saver"), 0, + _T(""), 0, KEY_READ, NULL, &hkey, NULL); len = sizeof value; - if(ERROR_SUCCESS == RegQueryValueEx(hkey, "MessageSpeed", 0, 0, (BYTE *)&value, &len)) + if(ERROR_SUCCESS == RegQueryValueEx(hkey, _T("MessageSpeed"), 0, 0, (BYTE *)&value, &len)) { if(value >= MSGSPEED_MIN && value <= MSGSPEED_MAX) g_nMessageSpeed = value; } - if(ERROR_SUCCESS == RegQueryValueEx(hkey, "MatrixSpeed", 0, 0, (BYTE *)&value, &len)) + if(ERROR_SUCCESS == RegQueryValueEx(hkey, _T("MatrixSpeed"), 0, 0, (BYTE *)&value, &len)) { if(value >= SPEED_MIN && value <= SPEED_MAX) g_nMatrixSpeed = value; } - if(ERROR_SUCCESS == RegQueryValueEx(hkey, "Density", 0, 0, (BYTE *)&value, &len)) + if(ERROR_SUCCESS == RegQueryValueEx(hkey, _T("Density"), 0, 0, (BYTE *)&value, &len)) { if(value >= DENSITY_MIN && value <= DENSITY_MAX) g_nDensity = value; } - if(ERROR_SUCCESS == RegQueryValueEx(hkey, "FontSize", 0, 0, (BYTE *)&value, &len)) + if(ERROR_SUCCESS == RegQueryValueEx(hkey, _T("FontSize"), 0, 0, (BYTE *)&value, &len)) { if(value >= FONT_MIN && value <= FONT_MAX) g_nFontSize = value; } - if(ERROR_SUCCESS == RegQueryValueEx(hkey, "FontBold", 0, 0, (BYTE *)&value, &len)) + if(ERROR_SUCCESS == RegQueryValueEx(hkey, _T("FontBold"), 0, 0, (BYTE *)&value, &len)) g_fFontBold = (value == 0 ? FALSE : TRUE); - if(ERROR_SUCCESS == RegQueryValueEx(hkey, "Randomize", 0, 0, (BYTE *)&value, &len)) + if(ERROR_SUCCESS == RegQueryValueEx(hkey, _T("Randomize"), 0, 0, (BYTE *)&value, &len)) g_fRandomizeMessages = (value == 0 ? FALSE : TRUE); len = 4096; - if(ERROR_SUCCESS == RegQueryValueEx(hkey, "FontName", 0, 0, (BYTE *)hugechar, &len)) + if(ERROR_SUCCESS == RegQueryValueEx(hkey, _T("FontName"), 0, 0, (BYTE *)hugechar, &len)) { if(len > 0) lstrcpy(g_szFontName, hugechar); else - lstrcpy(g_szFontName, "Arial"); + lstrcpy(g_szFontName, _T("Arial")); } len = 4096; - if(ERROR_SUCCESS == RegQueryValueEx(hkey, "Messages", 0, 0 , (BYTE *)hugechar, &len)) + if(ERROR_SUCCESS == RegQueryValueEx(hkey, _T("Messages"), 0, 0 , (BYTE *)hugechar, &len)) { while(len > 0 && *hptr && isascii(*hptr)) { @@ -96,7 +97,7 @@ void LoadSettings() else { /* built-in coded message for first run */ - lstrcpyn(g_szMessages[0], "ReactOS", MAXMSG_LENGTH); + lstrcpyn(g_szMessages[0], _T("ReactOS"), MAXMSG_LENGTH); } RegCloseKey(hkey); @@ -106,8 +107,8 @@ void LoadSettings() void SaveSettings() { HKEY hkey; - char *hugechar = malloc(4096); - char *msgptr = hugechar; + TCHAR *hugechar = malloc(4096); + TCHAR *msgptr = hugechar; int totallen = 0; int i,len; LONG value; @@ -115,31 +116,31 @@ void SaveSettings() if(hugechar == 0) return; - hugechar[0] = '\0'; + hugechar[0] = _T('\0'); msgptr = hugechar; - RegCreateKeyEx(HKEY_CURRENT_USER, "Software\\Catch22\\Matrix Screen Saver", 0, - "", 0, KEY_WRITE, NULL, &hkey, NULL); + RegCreateKeyEx(HKEY_CURRENT_USER, _T("Software\\Catch22\\Matrix Screen Saver"), 0, + _T(""), 0, KEY_WRITE, NULL, &hkey, NULL); value = g_nMessageSpeed; - RegSetValueEx(hkey, "MessageSpeed", 0, REG_DWORD, (BYTE *)&value, sizeof value); + RegSetValueEx(hkey, _T("MessageSpeed"), 0, REG_DWORD, (BYTE *)&value, sizeof value); value = g_nMatrixSpeed; - RegSetValueEx(hkey, "MatrixSpeed", 0, REG_DWORD, (BYTE *)&value, sizeof value); + RegSetValueEx(hkey, _T("MatrixSpeed"), 0, REG_DWORD, (BYTE *)&value, sizeof value); value = g_nDensity; - RegSetValueEx(hkey, "Density", 0, REG_DWORD, (BYTE *)&value, sizeof value); + RegSetValueEx(hkey, _T("Density"), 0, REG_DWORD, (BYTE *)&value, sizeof value); value = g_nFontSize; - RegSetValueEx(hkey, "FontSize", 0, REG_DWORD, (BYTE *)&value, sizeof value); + RegSetValueEx(hkey, _T("FontSize"), 0, REG_DWORD, (BYTE *)&value, sizeof value); value = g_fRandomizeMessages; - RegSetValueEx(hkey, "Randomize", 0, REG_DWORD, (BYTE *)&value, sizeof value); + RegSetValueEx(hkey, _T("Randomize"), 0, REG_DWORD, (BYTE *)&value, sizeof value); value = g_fFontBold; - RegSetValueEx(hkey, "FontBold", 0, REG_DWORD, (BYTE *)&value, sizeof value); + RegSetValueEx(hkey, _T("FontBold"), 0, REG_DWORD, (BYTE *)&value, sizeof value); - RegSetValueEx(hkey, "FontName", 0, REG_SZ, (BYTE *)g_szFontName, lstrlen(g_szFontName)); + RegSetValueEx(hkey, _T("FontName"), 0, REG_SZ, (BYTE *)g_szFontName, lstrlen(g_szFontName)); for(i = 0; i < g_nNumMessages; i++) { @@ -153,10 +154,10 @@ void SaveSettings() } } - *msgptr = '\0'; + *msgptr = _T('\0'); totallen++; - RegSetValueEx(hkey, "Messages", 0, REG_MULTI_SZ, (BYTE *)hugechar, totallen); + RegSetValueEx(hkey, _T("Messages"), 0, REG_MULTI_SZ, (BYTE *)hugechar, totallen); RegCloseKey(hkey); free(hugechar);