From 6d45e894ef5667cf0b70cba51b6afbcf1c73295b Mon Sep 17 00:00:00 2001 From: Ged Murphy Date: Fri, 9 Nov 2007 11:40:54 +0000 Subject: [PATCH] convert to unicode in an attempt to address bug 2805 svn path=/trunk/; revision=30289 --- reactos/base/applications/charmap/about.c | 48 +++-- reactos/base/applications/charmap/charmap.c | 221 +++++++++++--------- reactos/base/applications/charmap/lrgcell.c | 48 ++--- reactos/base/applications/charmap/map.c | 99 +++++---- reactos/base/applications/charmap/precomp.h | 6 +- 5 files changed, 219 insertions(+), 203 deletions(-) diff --git a/reactos/base/applications/charmap/about.c b/reactos/base/applications/charmap/about.c index dd9e7e354cf..c8a0040564b 100644 --- a/reactos/base/applications/charmap/about.c +++ b/reactos/base/applications/charmap/about.c @@ -24,30 +24,34 @@ AboutDialogProc(HWND hDlg, 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 @@ AboutDialogProc(HWND hDlg, VOID ShowAboutDlg(HWND hWndParent) { - DialogBox(hInstance, - MAKEINTRESOURCE(IDD_ABOUTBOX), - hWndParent, - AboutDialogProc); + DialogBoxW(hInstance, + MAKEINTRESOURCEW(IDD_ABOUTBOX), + hWndParent, + AboutDialogProc); } diff --git a/reactos/base/applications/charmap/charmap.c b/reactos/base/applications/charmap/charmap.c index f9a1f102e5c..61d1b4433f5 100644 --- a/reactos/base/applications/charmap/charmap.c +++ b/reactos/base/applications/charmap/charmap.c @@ -15,39 +15,39 @@ HINSTANCE hInstance; /* 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 @@ static VOID 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 @@ ChangeMapFont(HWND hDlg) { 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 @@ ChangeMapFont(HWND hDlg) 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 @@ ChangeMapFont(HWND hDlg) static VOID AddCharToSelection(HWND hText, - TCHAR ch) + WCHAR ch) { - LPTSTR lpText; + LPWSTR lpText; INT Len = GetWindowTextLength(hText); if (Len != 0) @@ -142,22 +142,22 @@ AddCharToSelection(HWND hText, if (lpText) { - LPTSTR lpStr = lpText; + LPWSTR lpStr = lpText; - SendMessage(hText, - WM_GETTEXT, - Len + 1, - (LPARAM)lpStr); + SendMessageW(hText, + WM_GETTEXT, + Len + 1, + (LPARAM)lpStr); lpStr += Len; *lpStr = ch; lpStr++; - *lpStr = _T('\0'); + *lpStr = L'\0'; - SendMessage(hText, - WM_SETTEXT, - 0, - (LPARAM)lpText); + SendMessageW(hText, + WM_SETTEXT, + 0, + (LPARAM)lpText); HeapFree(GetProcessHeap(), 0, @@ -166,15 +166,15 @@ AddCharToSelection(HWND hText, } else { - TCHAR szText[2]; + WCHAR szText[2]; szText[0] = ch; - szText[1] = _T('\0'); + szText[1] = L'\0'; - SendMessage(hText, - WM_SETTEXT, - 0, - (LPARAM)szText); + SendMessageW(hText, + WM_SETTEXT, + 0, + (LPARAM)szText); } } @@ -185,35 +185,42 @@ DlgProc(HWND hDlg, 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); + hSmIcon = LoadImageW(hInstance, + MAKEINTRESOURCEW(IDI_ICON), + IMAGE_ICON, + 16, + 16, + 0); + if (hSmIcon) + { + SendMessageW(hDlg, + WM_SETICON, + ICON_SMALL, + (LPARAM)hSmIcon); + } - SendMessage(hDlg, - WM_SETICON, - ICON_SMALL, - (LPARAM)hSmIcon); - SendMessage(hDlg, - WM_SETICON, - ICON_BIG, - (LPARAM)hBgIcon); + 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,33 +231,27 @@ DlgProc(HWND hDlg, FALSE); if (hSysMenu != NULL) { - LPCTSTR lpAboutText = NULL; + LPCWSTR lpAboutText = NULL; - if (LoadString(hInstance, - IDS_ABOUT, - (LPTSTR)&lpAboutText, - 0)) + 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; - case WM_COMMAND: { switch(LOWORD(wParam)) @@ -269,7 +270,7 @@ DlgProc(HWND hDlg, 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 @@ DlgProc(HWND hDlg, } case IDOK: + if (hSmIcon) + DestroyIcon(hSmIcon); + if (hBgIcon) + DestroyIcon(hBgIcon); EndDialog(hDlg, 0); break; } @@ -321,6 +326,14 @@ DlgProc(HWND hDlg, } break; + case WM_CLOSE: + if (hSmIcon) + DestroyIcon(hSmIcon); + if (hBgIcon) + DestroyIcon(hBgIcon); + EndDialog(hDlg, 0); + break; + default: return FALSE; } @@ -346,10 +359,10 @@ _tWinMain(HINSTANCE hInst, 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); } diff --git a/reactos/base/applications/charmap/lrgcell.c b/reactos/base/applications/charmap/lrgcell.c index c68f5b5f171..b94f288f9d6 100644 --- a/reactos/base/applications/charmap/lrgcell.c +++ b/reactos/base/applications/charmap/lrgcell.c @@ -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 @@ SetLrgFont(PMAP infoPtr) if (lpFontName) { - SendMessage(hCombo, - WM_GETTEXT, - 31, - (LPARAM)lpFontName); + SendMessageW(hCombo, + WM_GETTEXT, + 31, + (LPARAM)lpFontName); ZeroMemory(&lf, sizeof(lf)); @@ -48,10 +48,10 @@ SetLrgFont(PMAP infoPtr) 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 @@ LrgCellWndProc(HWND hwnd, 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 @@ LrgCellWndProc(HWND hwnd, { 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 @@ LrgCellWndProc(HWND hwnd, 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 @@ LrgCellWndProc(HWND hwnd, default: { HandleDefaultMessage: - Ret = DefWindowProc(hwnd, - uMsg, - wParam, - lParam); + Ret = DefWindowProcW(hwnd, + uMsg, + wParam, + lParam); break; } } diff --git a/reactos/base/applications/charmap/map.c b/reactos/base/applications/charmap/map.c index 679153d1046..bdb45101293 100644 --- a/reactos/base/applications/charmap/map.c +++ b/reactos/base/applications/charmap/map.c @@ -9,12 +9,12 @@ #include -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 @@ FillGrid(PMAP infoPtr, HDC hdc) { HFONT hOldFont; - TCHAR ch; + WCHAR ch; INT x, y; hOldFont = SelectObject(hdc, @@ -91,15 +91,15 @@ FillGrid(PMAP infoPtr, 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 @@ CreateLargeCell(PMAP infoPtr) 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 @@ MoveLargeCell(PMAP infoPtr) static VOID SetFont(PMAP infoPtr, - LPTSTR lpFontName) + LPWSTR lpFontName) { HDC hdc; @@ -183,7 +183,7 @@ SetFont(PMAP infoPtr, DeleteObject(infoPtr->hFont); ZeroMemory(&infoPtr->CurrentFont, - sizeof(LOGFONT)); + sizeof(LOGFONTW)); hdc = GetDC(infoPtr->hMapWnd); infoPtr->CurrentFont.lfHeight = GetDeviceCaps(hdc, @@ -191,10 +191,10 @@ SetFont(PMAP infoPtr, ReleaseDC(infoPtr->hMapWnd, hdc); infoPtr->CurrentFont.lfCharSet = DEFAULT_CHARSET; - lstrcpy(infoPtr->CurrentFont.lfFaceName, - lpFontName); + wcscpy(infoPtr->CurrentFont.lfFaceName, + lpFontName); - infoPtr->hFont = CreateFontIndirect(&infoPtr->CurrentFont); + infoPtr->hFont = CreateFontIndirectW(&infoPtr->CurrentFont); InvalidateRect(infoPtr->hMapWnd, NULL, @@ -205,7 +205,7 @@ SetFont(PMAP infoPtr, static LRESULT NotifyParentOfSelection(PMAP infoPtr, UINT code, - TCHAR ch) + WCHAR ch) { LRESULT Ret = 0; @@ -311,9 +311,9 @@ OnCreate(PMAP infoPtr, 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 @@ OnVScroll(PMAP infoPtr, } infoPtr->iPage = max(0, - min(infoPtr->iPage, - 255)); + min(infoPtr->iPage, 255)); SetScrollPos(infoPtr->hMapWnd, SB_VERT, @@ -440,8 +439,8 @@ MapWndProc(HWND hwnd, PMAP infoPtr; LRESULT Ret = 0; - infoPtr = (PMAP)GetWindowLongPtr(hwnd, - 0); + infoPtr = (PMAP)GetWindowLongPtrW(hwnd, + 0); switch (uMsg) { @@ -487,7 +486,7 @@ MapWndProc(HWND hwnd, case FM_SETFONT: { - LPTSTR lpFontName = (LPTSTR)lParam; + LPWSTR lpFontName = (LPWSTR)lParam; SetFont(infoPtr, lpFontName); @@ -518,18 +517,18 @@ MapWndProc(HWND hwnd, 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 @@ MapWndProc(HWND hwnd, 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 @@ RegisterMapClasses(HINSTANCE hInstance) VOID UnregisterMapClasses(HINSTANCE hInstance) { - UnregisterClass(szMapWndClass, + UnregisterClassW(szMapWndClass, hInstance); - UnregisterClass(szLrgCellWndClass, + UnregisterClassW(szLrgCellWndClass, hInstance); } diff --git a/reactos/base/applications/charmap/precomp.h b/reactos/base/applications/charmap/precomp.h index 49e3128c046..0f1185b0f32 100644 --- a/reactos/base/applications/charmap/precomp.h +++ b/reactos/base/applications/charmap/precomp.h @@ -23,7 +23,7 @@ typedef struct _CELL RECT CellInt; BOOL bActive; BOOL bLarge; - TCHAR ch; + WCHAR ch; } CELL, *PCELL; typedef struct _MAP @@ -36,13 +36,13 @@ typedef struct _MAP 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;