Author: gedmurphy Date: Fri Nov 9 14:40:54 2007 New Revision: 30289
URL: http://svn.reactos.org/svn/reactos?rev=30289&view=rev Log: convert to unicode in an attempt to address bug 2805
Modified: trunk/reactos/base/applications/charmap/about.c trunk/reactos/base/applications/charmap/charmap.c trunk/reactos/base/applications/charmap/lrgcell.c trunk/reactos/base/applications/charmap/map.c trunk/reactos/base/applications/charmap/precomp.h
Modified: trunk/reactos/base/applications/charmap/about.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/charmap/a... ============================================================================== --- trunk/reactos/base/applications/charmap/about.c (original) +++ trunk/reactos/base/applications/charmap/about.c Fri Nov 9 14:40:54 2007 @@ -24,30 +24,34 @@ case WM_INITDIALOG: { HWND hLicenseEditWnd; - TCHAR strLicense[700]; + WCHAR strLicense[700];
- hIcon = LoadImage(hInstance, - MAKEINTRESOURCE(IDI_ICON), - IMAGE_ICON, - 16, - 16, - 0); - - SendMessage(hDlg, - WM_SETICON, - ICON_SMALL, - (LPARAM)hIcon); + hIcon = LoadImageW(hInstance, + MAKEINTRESOURCEW(IDI_ICON), + IMAGE_ICON, + 16, + 16, + 0); + if (hIcon) + { + SendMessage(hDlg, + WM_SETICON, + ICON_SMALL, + (LPARAM)hIcon); + }
hLicenseEditWnd = GetDlgItem(hDlg, IDC_LICENSE_EDIT);
- LoadString(hInstance, - IDS_LICENSE, - strLicense, - sizeof(strLicense) / sizeof(TCHAR)); + if (LoadStringW(hInstance, + IDS_LICENSE, + strLicense, + sizeof(strLicense) / sizeof(WCHAR))) + { + SetWindowTextW(hLicenseEditWnd, + strLicense); + }
- SetWindowText(hLicenseEditWnd, - strLicense); return TRUE; }
@@ -72,8 +76,8 @@ VOID ShowAboutDlg(HWND hWndParent) { - DialogBox(hInstance, - MAKEINTRESOURCE(IDD_ABOUTBOX), - hWndParent, - AboutDialogProc); + DialogBoxW(hInstance, + MAKEINTRESOURCEW(IDD_ABOUTBOX), + hWndParent, + AboutDialogProc); }
Modified: trunk/reactos/base/applications/charmap/charmap.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/charmap/c... ============================================================================== --- trunk/reactos/base/applications/charmap/charmap.c (original) +++ trunk/reactos/base/applications/charmap/charmap.c Fri Nov 9 14:40:54 2007 @@ -15,39 +15,39 @@
/* Font-enumeration callback */ static int CALLBACK -EnumFontNames(ENUMLOGFONTEX *lpelfe, - NEWTEXTMETRICEX *lpntme, +EnumFontNames(ENUMLOGFONTEXW *lpelfe, + NEWTEXTMETRICEXW *lpntme, DWORD FontType, LPARAM lParam) { HWND hwndCombo = (HWND)lParam; - TCHAR *pszName = lpelfe->elfLogFont.lfFaceName; + LPWSTR pszName = lpelfe->elfLogFont.lfFaceName;
/* make sure font doesn't already exist in our list */ - if(SendMessage(hwndCombo, - CB_FINDSTRING, - 0, - (LPARAM)pszName) == CB_ERR) + if(SendMessageW(hwndCombo, + CB_FINDSTRING, + 0, + (LPARAM)pszName) == CB_ERR) { INT idx; BOOL fFixed; BOOL fTrueType;
/* add the font */ - idx = (INT)SendMessage(hwndCombo, - CB_ADDSTRING, - 0, - (LPARAM)pszName); + idx = (INT)SendMessageW(hwndCombo, + CB_ADDSTRING, + 0, + (LPARAM)pszName);
/* record the font's attributes (Fixedwidth and Truetype) */ fFixed = (lpelfe->elfLogFont.lfPitchAndFamily & FIXED_PITCH) ? TRUE : FALSE; fTrueType = (lpelfe->elfLogFont.lfOutPrecision == OUT_STROKE_PRECIS) ? TRUE : FALSE;
/* store this information in the list-item's userdata area */ - SendMessage(hwndCombo, - CB_SETITEMDATA, - idx, - MAKEWPARAM(fFixed, fTrueType)); + SendMessageW(hwndCombo, + CB_SETITEMDATA, + idx, + MAKEWPARAM(fFixed, fTrueType)); }
return 1; @@ -59,35 +59,35 @@ FillFontStyleComboList(HWND hwndCombo) { HDC hdc; - LOGFONT lf; + LOGFONTW lf;
/* FIXME: for fun, draw each font in its own style */ HFONT hFont = GetStockObject(DEFAULT_GUI_FONT); - SendMessage(hwndCombo, - WM_SETFONT, - (WPARAM)hFont, - 0); + SendMessageW(hwndCombo, + WM_SETFONT, + (WPARAM)hFont, + 0);
lf.lfCharSet = DEFAULT_CHARSET; - lf.lfFaceName[0] = _T('\0'); // all fonts + lf.lfFaceName[0] = L'\0'; // all fonts lf.lfPitchAndFamily = 0;
hdc = GetDC(hwndCombo);
/* store the list of fonts in the combo */ - EnumFontFamiliesEx(hdc, - &lf, - (FONTENUMPROC)EnumFontNames, - (LPARAM)hwndCombo, - 0); + EnumFontFamiliesExW(hdc, + &lf, + (FONTENUMPROCW)EnumFontNames, + (LPARAM)hwndCombo, + 0);
ReleaseDC(hwndCombo, hdc);
- SendMessage(hwndCombo, - CB_SETCURSEL, - 0, - 0); + SendMessageW(hwndCombo, + CB_SETCURSEL, + 0, + 0); }
@@ -96,12 +96,12 @@ { HWND hCombo; HWND hMap; - LPTSTR lpFontName; + LPWSTR lpFontName; INT Len;
hCombo = GetDlgItem(hDlg, IDC_FONTCOMBO);
- Len = GetWindowTextLength(hCombo); + Len = GetWindowTextLengthW(hCombo);
if (Len != 0) { @@ -111,17 +111,17 @@
if (lpFontName) { - SendMessage(hCombo, - WM_GETTEXT, - Len + 1, - (LPARAM)lpFontName); + SendMessageW(hCombo, + WM_GETTEXT, + Len + 1, + (LPARAM)lpFontName);
hMap = GetDlgItem(hDlg, IDC_FONTMAP);
- SendMessage(hMap, - FM_SETFONT, - 0, - (LPARAM)lpFontName); + SendMessageW(hMap, + FM_SETFONT, + 0, + (LPARAM)lpFontName); } } } @@ -129,9 +129,9 @@
static VOID AddCharToSelection(HWND hText, - TCHAR ch) -{ - LPTSTR lpText; + WCHAR ch) +{ + LPWSTR lpText; INT Len = GetWindowTextLength(hText);
if (Len != 0) @@ -142,22 +142,22 @@
if (lpText) { - LPTSTR lpStr = lpText; - - SendMessage(hText, - WM_GETTEXT, - Len + 1, - (LPARAM)lpStr); + LPWSTR lpStr = lpText; + + SendMessageW(hText, + WM_GETTEXT, + Len + 1, + (LPARAM)lpStr);
lpStr += Len; *lpStr = ch; lpStr++; - *lpStr = _T('\0'); - - SendMessage(hText, - WM_SETTEXT, - 0, - (LPARAM)lpText); + *lpStr = L'\0'; + + SendMessageW(hText, + WM_SETTEXT, + 0, + (LPARAM)lpText);
HeapFree(GetProcessHeap(), 0, @@ -166,15 +166,15 @@ } else { - TCHAR szText[2]; + WCHAR szText[2];
szText[0] = ch; - szText[1] = _T('\0'); - - SendMessage(hText, - WM_SETTEXT, - 0, - (LPARAM)szText); + szText[1] = L'\0'; + + SendMessageW(hText, + WM_SETTEXT, + 0, + (LPARAM)szText); } }
@@ -185,35 +185,42 @@ WPARAM wParam, LPARAM lParam) { + static HICON hSmIcon; + static HICON hBgIcon; + switch(Message) { case WM_INITDIALOG: { - HICON hSmIcon; - HICON hBgIcon; HMENU hSysMenu;
- hSmIcon = LoadImage(hInstance, - MAKEINTRESOURCE(IDI_ICON), - IMAGE_ICON, - 16, - 16, - 0); - hBgIcon = LoadImage(hInstance, - MAKEINTRESOURCE(IDI_ICON), - IMAGE_ICON, - 32, - 32, - 0); - - SendMessage(hDlg, - WM_SETICON, - ICON_SMALL, - (LPARAM)hSmIcon); - SendMessage(hDlg, - WM_SETICON, - ICON_BIG, - (LPARAM)hBgIcon); + hSmIcon = LoadImageW(hInstance, + MAKEINTRESOURCEW(IDI_ICON), + IMAGE_ICON, + 16, + 16, + 0); + if (hSmIcon) + { + SendMessageW(hDlg, + WM_SETICON, + ICON_SMALL, + (LPARAM)hSmIcon); + } + + hBgIcon = LoadImageW(hInstance, + MAKEINTRESOURCEW(IDI_ICON), + IMAGE_ICON, + 32, + 32, + 0); + if (hBgIcon) + { + SendMessageW(hDlg, + WM_SETICON, + ICON_BIG, + (LPARAM)hBgIcon); + }
FillFontStyleComboList(GetDlgItem(hDlg, IDC_FONTCOMBO)); @@ -224,30 +231,24 @@ FALSE); if (hSysMenu != NULL) { - LPCTSTR lpAboutText = NULL; - - if (LoadString(hInstance, - IDS_ABOUT, - (LPTSTR)&lpAboutText, - 0)) + LPCWSTR lpAboutText = NULL; + + if (LoadStringW(hInstance, + IDS_ABOUT, + (LPWSTR)&lpAboutText, + 0)) { - AppendMenu(hSysMenu, - MF_SEPARATOR, - 0, - NULL); - AppendMenu(hSysMenu, - MF_STRING, - ID_ABOUT, - lpAboutText); + AppendMenuW(hSysMenu, + MF_SEPARATOR, + 0, + NULL); + AppendMenuW(hSysMenu, + MF_STRING, + ID_ABOUT, + lpAboutText); } } return TRUE; - } - break; - - case WM_CLOSE: - { - EndDialog(hDlg, 0); } break;
@@ -269,7 +270,7 @@ TCHAR ch; HWND hMap = GetDlgItem(hDlg, IDC_FONTMAP);
- ch = (TCHAR) SendMessage(hMap, FM_GETCHAR, 0, 0); + ch = (TCHAR) SendMessageW(hMap, FM_GETCHAR, 0, 0);
if (ch) { @@ -281,6 +282,10 @@ }
case IDOK: + if (hSmIcon) + DestroyIcon(hSmIcon); + if (hBgIcon) + DestroyIcon(hBgIcon); EndDialog(hDlg, 0); break; } @@ -321,6 +326,14 @@ } break;
+ case WM_CLOSE: + if (hSmIcon) + DestroyIcon(hSmIcon); + if (hBgIcon) + DestroyIcon(hBgIcon); + EndDialog(hDlg, 0); + break; + default: return FALSE; } @@ -346,10 +359,10 @@
if (RegisterMapClasses(hInstance)) { - Ret = DialogBox(hInstance, - MAKEINTRESOURCE(IDD_CHARMAP), - NULL, - (DLGPROC)DlgProc) >= 0; + Ret = DialogBoxW(hInstance, + MAKEINTRESOURCEW(IDD_CHARMAP), + NULL, + (DLGPROC)DlgProc) >= 0;
UnregisterMapClasses(hInstance); }
Modified: trunk/reactos/base/applications/charmap/lrgcell.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/charmap/l... ============================================================================== --- trunk/reactos/base/applications/charmap/lrgcell.c (original) +++ trunk/reactos/base/applications/charmap/lrgcell.c Fri Nov 9 14:40:54 2007 @@ -13,17 +13,17 @@ static HFONT SetLrgFont(PMAP infoPtr) { - LOGFONT lf; + LOGFONTW lf; HFONT hFont = NULL; HDC hdc; HWND hCombo; - LPTSTR lpFontName; + LPWSTR lpFontName; INT Len;
hCombo = GetDlgItem(infoPtr->hParent, IDC_FONTCOMBO);
- Len = GetWindowTextLength(hCombo); + Len = GetWindowTextLengthW(hCombo);
if (Len != 0) { @@ -33,10 +33,10 @@
if (lpFontName) { - SendMessage(hCombo, - WM_GETTEXT, - 31, - (LPARAM)lpFontName); + SendMessageW(hCombo, + WM_GETTEXT, + 31, + (LPARAM)lpFontName);
ZeroMemory(&lf, sizeof(lf)); @@ -48,10 +48,10 @@ hdc);
lf.lfCharSet = DEFAULT_CHARSET; - lstrcpy(lf.lfFaceName, - lpFontName); + wcscpy(lf.lfFaceName, + lpFontName);
- hFont = CreateFontIndirect(&lf); + hFont = CreateFontIndirectW(&lf);
HeapFree(GetProcessHeap(), 0, @@ -75,7 +75,7 @@ static RECT rc; static HFONT hFont = NULL;
- infoPtr = (PMAP)GetWindowLongPtr(hwnd, + infoPtr = (PMAP)GetWindowLongPtrW(hwnd, GWLP_USERDATA);
if (infoPtr == NULL && uMsg != WM_CREATE) @@ -87,11 +87,11 @@ { case WM_CREATE: { - infoPtr = (PMAP)(((LPCREATESTRUCT)lParam)->lpCreateParams); + infoPtr = (PMAP)(((LPCREATESTRUCTW)lParam)->lpCreateParams);
- SetWindowLongPtr(hwnd, - GWLP_USERDATA, - (LONG_PTR)infoPtr); + SetWindowLongPtrW(hwnd, + GWLP_USERDATA, + (LONG_PTR)infoPtr);
hFont = SetLrgFont(infoPtr);
@@ -128,11 +128,11 @@
hOldFont = SelectObject(hdc, hFont);
- DrawText(hdc, - &infoPtr->pActiveCell->ch, - 1, - &rc, - DT_CENTER | DT_VCENTER | DT_SINGLELINE); + DrawTextW(hdc, + &infoPtr->pActiveCell->ch, + 1, + &rc, + DT_CENTER | DT_VCENTER | DT_SINGLELINE);
SelectObject(hdc, hOldFont);
@@ -152,10 +152,10 @@ default: { HandleDefaultMessage: - Ret = DefWindowProc(hwnd, - uMsg, - wParam, - lParam); + Ret = DefWindowProcW(hwnd, + uMsg, + wParam, + lParam); break; } }
Modified: trunk/reactos/base/applications/charmap/map.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/charmap/m... ============================================================================== --- trunk/reactos/base/applications/charmap/map.c (original) +++ trunk/reactos/base/applications/charmap/map.c Fri Nov 9 14:40:54 2007 @@ -9,12 +9,12 @@
#include <precomp.h>
-static const TCHAR szMapWndClass[] = TEXT("FontMapWnd"); -static const TCHAR szLrgCellWndClass[] = TEXT("LrgCellWnd"); +static const WCHAR szMapWndClass[] = L"FontMapWnd"; +static const WCHAR szLrgCellWndClass[] = L"LrgCellWnd";
static VOID TagFontToCell(PCELL pCell, - TCHAR ch) + WCHAR ch) { pCell->ch = ch; } @@ -82,7 +82,7 @@ HDC hdc) { HFONT hOldFont; - TCHAR ch; + WCHAR ch; INT x, y;
hOldFont = SelectObject(hdc, @@ -91,15 +91,15 @@ for (y = 0; y < YCELLS; y++) for (x = 0; x < XCELLS; x++) { - ch = (TCHAR)((256 * infoPtr->iPage) + (XCELLS * y) + x); + ch = (WCHAR)((256 * infoPtr->iPage) + (XCELLS * y) + x);
TagFontToCell(&infoPtr->Cells[y][x], ch);
- DrawText(hdc, - &ch, - 1, - &infoPtr->Cells[y][x].CellInt, - DT_CENTER | DT_VCENTER | DT_SINGLELINE); + DrawTextW(hdc, + &ch, + 1, + &infoPtr->Cells[y][x].CellInt, + DT_CENTER | DT_VCENTER | DT_SINGLELINE); }
SelectObject(hdc, @@ -124,18 +124,18 @@ XLARGE - XCELLS, YLARGE - YCELLS);
- infoPtr->hLrgWnd = CreateWindowEx(0, - szLrgCellWndClass, - NULL, - WS_CHILDWINDOW | WS_VISIBLE, - rLarge.left, - rLarge.top, - rLarge.right - rLarge.left, - rLarge.bottom - rLarge.top, - infoPtr->hParent, - NULL, - hInstance, - infoPtr); + infoPtr->hLrgWnd = CreateWindowExW(0, + szLrgCellWndClass, + NULL, + WS_CHILDWINDOW | WS_VISIBLE, + rLarge.left, + rLarge.top, + rLarge.right - rLarge.left, + rLarge.bottom - rLarge.top, + infoPtr->hParent, + NULL, + hInstance, + infoPtr); if (!infoPtr->hLrgWnd) return FALSE;
@@ -175,7 +175,7 @@
static VOID SetFont(PMAP infoPtr, - LPTSTR lpFontName) + LPWSTR lpFontName) { HDC hdc;
@@ -183,7 +183,7 @@ DeleteObject(infoPtr->hFont);
ZeroMemory(&infoPtr->CurrentFont, - sizeof(LOGFONT)); + sizeof(LOGFONTW));
hdc = GetDC(infoPtr->hMapWnd); infoPtr->CurrentFont.lfHeight = GetDeviceCaps(hdc, @@ -191,10 +191,10 @@ ReleaseDC(infoPtr->hMapWnd, hdc);
infoPtr->CurrentFont.lfCharSet = DEFAULT_CHARSET; - lstrcpy(infoPtr->CurrentFont.lfFaceName, - lpFontName); - - infoPtr->hFont = CreateFontIndirect(&infoPtr->CurrentFont); + wcscpy(infoPtr->CurrentFont.lfFaceName, + lpFontName); + + infoPtr->hFont = CreateFontIndirectW(&infoPtr->CurrentFont);
InvalidateRect(infoPtr->hMapWnd, NULL, @@ -205,7 +205,7 @@ static LRESULT NotifyParentOfSelection(PMAP infoPtr, UINT code, - TCHAR ch) + WCHAR ch) { LRESULT Ret = 0;
@@ -311,9 +311,9 @@ if (infoPtr) { SetLastError(0); - SetWindowLongPtr(hwnd, - 0, - (DWORD_PTR)infoPtr); + SetWindowLongPtrW(hwnd, + 0, + (DWORD_PTR)infoPtr); if (GetLastError() == 0) { ZeroMemory(infoPtr, @@ -375,8 +375,7 @@ }
infoPtr->iPage = max(0, - min(infoPtr->iPage, - 255)); + min(infoPtr->iPage, 255));
SetScrollPos(infoPtr->hMapWnd, SB_VERT, @@ -440,8 +439,8 @@ PMAP infoPtr; LRESULT Ret = 0;
- infoPtr = (PMAP)GetWindowLongPtr(hwnd, - 0); + infoPtr = (PMAP)GetWindowLongPtrW(hwnd, + 0);
switch (uMsg) { @@ -487,7 +486,7 @@
case FM_SETFONT: { - LPTSTR lpFontName = (LPTSTR)lParam; + LPWSTR lpFontName = (LPWSTR)lParam;
SetFont(infoPtr, lpFontName); @@ -518,18 +517,18 @@ HeapFree(GetProcessHeap(), 0, infoPtr); - SetWindowLongPtr(hwnd, - 0, - (DWORD_PTR)NULL); + SetWindowLongPtrW(hwnd, + 0, + (DWORD_PTR)NULL); break; }
default: { - Ret = DefWindowProc(hwnd, - uMsg, - wParam, - lParam); + Ret = DefWindowProcW(hwnd, + uMsg, + wParam, + lParam); break; } } @@ -541,24 +540,24 @@ BOOL RegisterMapClasses(HINSTANCE hInstance) { - WNDCLASS wc = {0}; + WNDCLASSW wc = {0};
wc.style = CS_DBLCLKS; wc.lpfnWndProc = MapWndProc; wc.cbWndExtra = sizeof(PMAP); wc.hInstance = hInstance; - wc.hCursor = LoadCursor(NULL, - (LPTSTR)IDC_ARROW); + wc.hCursor = LoadCursorW(NULL, + (LPWSTR)IDC_ARROW); wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); wc.lpszClassName = szMapWndClass;
- if (RegisterClass(&wc)) + if (RegisterClassW(&wc)) { wc.lpfnWndProc = LrgCellWndProc; wc.cbWndExtra = 0; wc.lpszClassName = szLrgCellWndClass;
- return RegisterClass(&wc) != 0; + return RegisterClassW(&wc) != 0; }
return FALSE; @@ -567,9 +566,9 @@ VOID UnregisterMapClasses(HINSTANCE hInstance) { - UnregisterClass(szMapWndClass, + UnregisterClassW(szMapWndClass, hInstance);
- UnregisterClass(szLrgCellWndClass, + UnregisterClassW(szLrgCellWndClass, hInstance); }
Modified: trunk/reactos/base/applications/charmap/precomp.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/charmap/p... ============================================================================== --- trunk/reactos/base/applications/charmap/precomp.h (original) +++ trunk/reactos/base/applications/charmap/precomp.h Fri Nov 9 14:40:54 2007 @@ -23,7 +23,7 @@ RECT CellInt; BOOL bActive; BOOL bLarge; - TCHAR ch; + WCHAR ch; } CELL, *PCELL;
typedef struct _MAP @@ -36,13 +36,13 @@ CELL Cells[YCELLS][XCELLS]; PCELL pActiveCell; HFONT hFont; - LOGFONT CurrentFont; + LOGFONTW CurrentFont; INT iPage; } MAP, *PMAP;
typedef struct { NMHDR hdr; - TCHAR ch; + WCHAR ch; } MAPNOTIFY, *LPMAPNOTIFY;