Author: dgorbachev Date: Wed May 27 21:56:50 2009 New Revision: 41147
URL: http://svn.reactos.org/svn/reactos?rev=41147&view=rev Log: Change Paint to use Unicode
Modified: trunk/reactos/base/applications/paint/definitions.h trunk/reactos/base/applications/paint/dib.c trunk/reactos/base/applications/paint/dib.h trunk/reactos/base/applications/paint/globalvar.h trunk/reactos/base/applications/paint/main.c trunk/reactos/base/applications/paint/paint.rbuild trunk/reactos/base/applications/paint/winproc.c
Modified: trunk/reactos/base/applications/paint/definitions.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/paint/def... ============================================================================== --- trunk/reactos/base/applications/paint/definitions.h [iso-8859-1] (original) +++ trunk/reactos/base/applications/paint/definitions.h [iso-8859-1] Wed May 27 21:56:50 2009 @@ -7,6 +7,8 @@ */
/* DEFINES **********************************************************/ + +#define SIZEOF(a) (sizeof(a) / sizeof((a)[0]))
#define IDI_APPICON 500
Modified: trunk/reactos/base/applications/paint/dib.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/paint/dib... ============================================================================== --- trunk/reactos/base/applications/paint/dib.c [iso-8859-1] (original) +++ trunk/reactos/base/applications/paint/dib.c [iso-8859-1] Wed May 27 21:56:50 2009 @@ -43,7 +43,7 @@ return bm.bmHeight; }
-void SaveDIBToFile(HBITMAP hbm, LPSTR name, HDC hdc) +void SaveDIBToFile(HBITMAP hbm, LPTSTR name, HDC hdc) { BITMAP bm; GetObject(hbm, sizeof(BITMAP), &bm); @@ -77,7 +77,7 @@ HeapFree(GetProcessHeap(), 0, buffer); }
-HBITMAP LoadDIBFromFile(LPSTR name) +HBITMAP LoadDIBFromFile(LPTSTR name) { HBITMAP bm; BITMAPFILEHEADER bfh;
Modified: trunk/reactos/base/applications/paint/dib.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/paint/dib... ============================================================================== --- trunk/reactos/base/applications/paint/dib.h [iso-8859-1] (original) +++ trunk/reactos/base/applications/paint/dib.h [iso-8859-1] Wed May 27 21:56:50 2009 @@ -12,6 +12,6 @@
int GetDIBHeight(HBITMAP hbm);
-void SaveDIBToFile(HBITMAP hbm, LPSTR name, HDC hdc); +void SaveDIBToFile(HBITMAP hbm, LPTSTR name, HDC hdc);
-HBITMAP LoadDIBFromFile(LPSTR name); +HBITMAP LoadDIBFromFile(LPTSTR name);
Modified: trunk/reactos/base/applications/paint/globalvar.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/paint/glo... ============================================================================== --- trunk/reactos/base/applications/paint/globalvar.h [iso-8859-1] (original) +++ trunk/reactos/base/applications/paint/globalvar.h [iso-8859-1] Wed May 27 21:56:50 2009 @@ -68,6 +68,6 @@
extern HINSTANCE hProgInstance;
-extern char filename[256]; -extern char filepathname[1000]; +extern TCHAR filename[256]; +extern TCHAR filepathname[1000]; extern BOOL isAFile;
Modified: trunk/reactos/base/applications/paint/main.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/paint/mai... ============================================================================== --- trunk/reactos/base/applications/paint/main.c [iso-8859-1] (original) +++ trunk/reactos/base/applications/paint/main.c [iso-8859-1] Wed May 27 21:56:50 2009 @@ -12,6 +12,7 @@ #include <windowsx.h> #include <commctrl.h> #include <stdio.h> +#include <tchar.h> #include "definitions.h"
#include "drawing.h" @@ -97,11 +98,11 @@
HINSTANCE hProgInstance;
-char filename[256]; -char filepathname[1000]; +TCHAR filename[256]; +TCHAR filepathname[1000]; BOOL isAFile = FALSE;
-int WINAPI WinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpszArgument, int nFunsterStil) +int WINAPI _tWinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPTSTR lpszArgument, int nFunsterStil) { hProgInstance = hThisInstance; HWND hwnd; /* This is the handle for our window */ @@ -113,7 +114,7 @@ //initializing and registering the window class used for the main window WNDCLASSEX wincl; wincl.hInstance = hThisInstance; - wincl.lpszClassName = "WindowsApp"; + wincl.lpszClassName = _T("WindowsApp"); wincl.lpfnWndProc = WindowProcedure; wincl.style = CS_DBLCLKS; wincl.cbSize = sizeof (WNDCLASSEX); @@ -130,7 +131,7 @@
WNDCLASSEX wclScroll; wclScroll.hInstance = hThisInstance; - wclScroll.lpszClassName = "Scrollbox"; + wclScroll.lpszClassName = _T("Scrollbox"); wclScroll.lpfnWndProc = WindowProcedure; wclScroll.style = 0; wclScroll.cbSize = sizeof (WNDCLASSEX); @@ -147,7 +148,7 @@
WNDCLASSEX wclPal; wclPal.hInstance = hThisInstance; - wclPal.lpszClassName = "Palette"; + wclPal.lpszClassName = _T("Palette"); wclPal.lpfnWndProc = PalWinProc; wclPal.style = CS_DBLCLKS; wclPal.cbSize = sizeof (WNDCLASSEX); @@ -164,7 +165,7 @@
WNDCLASSEX wclSettings; wclSettings.hInstance = hThisInstance; - wclSettings.lpszClassName = "ToolSettings"; + wclSettings.lpszClassName = _T("ToolSettings"); wclSettings.lpfnWndProc = SettingsWinProc; wclSettings.style = CS_DBLCLKS; wclSettings.cbSize = sizeof (WNDCLASSEX); @@ -181,7 +182,7 @@
WNDCLASSEX wclSelection; wclSelection.hInstance = hThisInstance; - wclSelection.lpszClassName = "Selection"; + wclSelection.lpszClassName = _T("Selection"); wclSelection.lpfnWndProc = SelectionWinProc; wclSelection.style = CS_DBLCLKS; wclSelection.cbSize = sizeof (WNDCLASSEX); @@ -194,15 +195,15 @@ wclSelection.hbrBackground = NULL;//GetSysColorBrush(COLOR_BTNFACE); RegisterClassEx (&wclSelection);
- LoadString(hThisInstance, IDS_DEFAULTFILENAME, (LPTSTR)filename, sizeof(filename)); - char progtitle[1000]; - char resstr[100]; - LoadString(hThisInstance, IDS_WINDOWTITLE, (LPTSTR)resstr, sizeof(resstr)); - sprintf(progtitle, resstr, filename); + LoadString(hThisInstance, IDS_DEFAULTFILENAME, filename, SIZEOF(filename)); + TCHAR progtitle[1000]; + TCHAR resstr[100]; + LoadString(hThisInstance, IDS_WINDOWTITLE, resstr, SIZEOF(resstr)); + _stprintf(progtitle, resstr, filename);
// create main window - hwnd = CreateWindowEx (0, "WindowsApp", (LPTSTR)progtitle, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 544, 375, HWND_DESKTOP, NULL, hThisInstance, NULL); + hwnd = CreateWindowEx (0, _T("WindowsApp"), progtitle, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 544, 375, HWND_DESKTOP, NULL, hThisInstance, NULL);
hMainWnd = hwnd;
@@ -222,7 +223,7 @@ hCurPen = LoadIcon(hThisInstance, MAKEINTRESOURCE(IDC_PEN)); hCurAirbrush = LoadIcon(hThisInstance, MAKEINTRESOURCE(IDC_AIRBRUSH));
- HWND hLine = CreateWindowEx (0, "STATIC", "", WS_CHILD | WS_VISIBLE | SS_ETCHEDHORZ, 0, 0, 5000, 2, hwnd, NULL, hThisInstance, NULL); + HWND hLine = CreateWindowEx (0, _T("STATIC"), _T(""), WS_CHILD | WS_VISIBLE | SS_ETCHEDHORZ, 0, 0, 5000, 2, hwnd, NULL, hThisInstance, NULL);
// creating the 16 bitmap radio buttons and setting the bitmap
@@ -236,12 +237,12 @@ DeleteObject(tempBm); SendMessage(hToolbar, TB_BUTTONSTRUCTSIZE, sizeof(TBBUTTON), 0); int i; - char tooltips[16][30]; + TCHAR tooltips[16][30]; for (i=0; i<16; i++) { int wrapnow = 0; if (i % 2 == 1) wrapnow = TBSTATE_WRAP; - LoadString(hThisInstance, IDS_TOOLTIP1 + i, (LPTSTR)tooltips[i], 30); + LoadString(hThisInstance, IDS_TOOLTIP1 + i, tooltips[i], 30); TBBUTTON tbbutton = { i, ID_FREESEL + i, TBSTATE_ENABLED | wrapnow, TBSTYLE_CHECKGROUP, {0}, 0, (INT_PTR)tooltips[i] }; SendMessage(hToolbar, TB_ADDBUTTONS, 1, (LPARAM)&tbbutton); } @@ -256,25 +257,25 @@
// creating the tool settings child window - hToolSettings = CreateWindowEx(0, "ToolSettings", "", WS_CHILD | WS_VISIBLE, 7, 210, 42, 140, hwnd, NULL, hThisInstance, NULL); + hToolSettings = CreateWindowEx(0, _T("ToolSettings"), _T(""), WS_CHILD | WS_VISIBLE, 7, 210, 42, 140, hwnd, NULL, hThisInstance, NULL);
// creating the palette child window - hPalWin = CreateWindowEx(0, "Palette", "", WS_CHILD | WS_VISIBLE, 56, 9, 255, 32, hwnd, NULL, hThisInstance, NULL); + hPalWin = CreateWindowEx(0, _T("Palette"), _T(""), WS_CHILD | WS_VISIBLE, 56, 9, 255, 32, hwnd, NULL, hThisInstance, NULL);
// creating the scroll box - hScrollbox = CreateWindowEx (WS_EX_CLIENTEDGE, "Scrollbox", "", WS_CHILD | WS_GROUP | WS_HSCROLL | WS_VSCROLL | WS_VISIBLE, 56, 49, 472, 248, hwnd, NULL, hThisInstance, NULL); + hScrollbox = CreateWindowEx (WS_EX_CLIENTEDGE, _T("Scrollbox"), _T(""), WS_CHILD | WS_GROUP | WS_HSCROLL | WS_VSCROLL | WS_VISIBLE, 56, 49, 472, 248, hwnd, NULL, hThisInstance, NULL);
// creating the status bar - hStatusBar = CreateWindowEx (0, STATUSCLASSNAME, "", SBARS_SIZEGRIP | WS_CHILD | WS_VISIBLE, 0, 0, 0, 0, hwnd, NULL, hThisInstance, NULL); + hStatusBar = CreateWindowEx (0, STATUSCLASSNAME, _T(""), SBARS_SIZEGRIP | WS_CHILD | WS_VISIBLE, 0, 0, 0, 0, hwnd, NULL, hThisInstance, NULL); SendMessage(hStatusBar, SB_SETMINHEIGHT, 21, 0);
- hScrlClient = CreateWindowEx(0, "Scrollbox", "", WS_CHILD | WS_VISIBLE, 0, 0, 500, 500, hScrollbox, NULL, hThisInstance, NULL); + hScrlClient = CreateWindowEx(0, _T("Scrollbox"), _T(""), WS_CHILD | WS_VISIBLE, 0, 0, 500, 500, hScrollbox, NULL, hThisInstance, NULL);
// create selection window (initially hidden) - hSelection = CreateWindowEx(WS_EX_TRANSPARENT, "Selection", "", WS_CHILD | BS_OWNERDRAW, 350, 0, 100, 100, hScrlClient, NULL, hThisInstance, NULL); + hSelection = CreateWindowEx(WS_EX_TRANSPARENT, _T("Selection"), _T(""), WS_CHILD | BS_OWNERDRAW, 350, 0, 100, 100, hScrlClient, NULL, hThisInstance, NULL);
// creating the window inside the scroll box, on which the image in hDrawingDC's bitmap is drawn - hImageArea = CreateWindowEx (0, "Scrollbox", "", WS_CHILD | WS_VISIBLE, 3, 3, imgXRes, imgYRes, hScrlClient, NULL, hThisInstance, NULL); + hImageArea = CreateWindowEx (0, _T("Scrollbox"), _T(""), WS_CHILD | WS_VISIBLE, 3, 3, imgXRes, imgYRes, hScrlClient, NULL, hThisInstance, NULL);
hDrawingDC = CreateCompatibleDC(GetDC(hImageArea)); hSelDC = CreateCompatibleDC(GetDC(hImageArea)); @@ -299,41 +300,41 @@ choosecolor.lpfnHook = NULL; choosecolor.lpTemplateName = NULL;
- char *c; + TCHAR *c;
// initializing the OPENFILENAME structure for use with GetOpenFileName and GetSaveFileName - char ofnFilename[1000]; + TCHAR ofnFilename[1000]; CopyMemory(ofnFilename, filename, sizeof(filename)); - char ofnFiletitle[256]; - char ofnFilter[1000]; - LoadString(hThisInstance, IDS_OPENFILTER, (LPTSTR)ofnFilter, sizeof(ofnFilter)); + TCHAR ofnFiletitle[256]; + TCHAR ofnFilter[1000]; + LoadString(hThisInstance, IDS_OPENFILTER, ofnFilter, SIZEOF(ofnFilter)); for (c = ofnFilter; *c; c++) if (*c == '\1') *c = '\0'; ZeroMemory(&ofn, sizeof(OPENFILENAME)); ofn.lStructSize = sizeof (OPENFILENAME); ofn.hwndOwner = hwnd; ofn.hInstance = hThisInstance; - ofn.lpstrFilter = (LPCTSTR)ofnFilter; - ofn.lpstrFile = (LPTSTR)ofnFilename; - ofn.nMaxFile = sizeof(ofnFilename); - ofn.lpstrFileTitle = (LPTSTR)ofnFiletitle; - ofn.nMaxFileTitle = sizeof(ofnFiletitle); + ofn.lpstrFilter = ofnFilter; + ofn.lpstrFile = ofnFilename; + ofn.nMaxFile = SIZEOF(ofnFilename); + ofn.lpstrFileTitle = ofnFiletitle; + ofn.nMaxFileTitle = SIZEOF(ofnFiletitle); ofn.Flags = OFN_HIDEREADONLY;
- char sfnFilename[1000]; + TCHAR sfnFilename[1000]; CopyMemory(sfnFilename, filename, sizeof(filename)); - char sfnFiletitle[256]; - char sfnFilter[1000]; - LoadString(hThisInstance, IDS_SAVEFILTER, (LPTSTR)sfnFilter, sizeof(sfnFilter)); + TCHAR sfnFiletitle[256]; + TCHAR sfnFilter[1000]; + LoadString(hThisInstance, IDS_SAVEFILTER, sfnFilter, SIZEOF(sfnFilter)); for (c = sfnFilter; *c; c++) if (*c == '\1') *c = '\0'; ZeroMemory(&sfn, sizeof(OPENFILENAME)); sfn.lStructSize = sizeof (OPENFILENAME); sfn.hwndOwner = hwnd; sfn.hInstance = hThisInstance; - sfn.lpstrFilter = (LPCTSTR)sfnFilter; - sfn.lpstrFile = (LPTSTR)sfnFilename; - sfn.nMaxFile = sizeof(sfnFilename); - sfn.lpstrFileTitle = (LPTSTR)sfnFiletitle; - sfn.nMaxFileTitle = sizeof(sfnFiletitle); + sfn.lpstrFilter = sfnFilter; + sfn.lpstrFile = sfnFilename; + sfn.nMaxFile = SIZEOF(sfnFilename); + sfn.lpstrFileTitle = sfnFiletitle; + sfn.nMaxFileTitle = SIZEOF(sfnFiletitle); sfn.Flags = OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY;
Modified: trunk/reactos/base/applications/paint/paint.rbuild URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/paint/pai... ============================================================================== --- trunk/reactos/base/applications/paint/paint.rbuild [iso-8859-1] (original) +++ trunk/reactos/base/applications/paint/paint.rbuild [iso-8859-1] Wed May 27 21:56:50 2009 @@ -1,6 +1,6 @@ <?xml version="1.0"?> <!DOCTYPE module SYSTEM "../../../tools/rbuild/project.dtd"> -<module name="paint" type="win32gui" installbase="system32" installname="paint.exe" allowwarnings="true"> +<module name="paint" type="win32gui" installbase="system32" installname="paint.exe" unicode="yes" allowwarnings="true"> <include base="paint">.</include> <library>comdlg32</library> <library>shell32</library>
Modified: trunk/reactos/base/applications/paint/winproc.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/paint/win... ============================================================================== --- trunk/reactos/base/applications/paint/winproc.c [iso-8859-1] (original) +++ trunk/reactos/base/applications/paint/winproc.c [iso-8859-1] Wed May 27 21:56:50 2009 @@ -13,6 +13,7 @@ #include <commctrl.h> //#include <htmlhelp.h> #include <stdio.h> +#include <tchar.h> #include "definitions.h" #include "globalvar.h" #include "dialogs.h" @@ -60,13 +61,13 @@ case WM_CLOSE: if (undoSteps>0) { - char programname[20]; - char saveprompttext[100]; - LoadString(hProgInstance, IDS_PROGRAMNAME, (LPTSTR)programname, sizeof(programname)); - LoadString(hProgInstance, IDS_SAVEPROMPTTEXT, (LPTSTR)saveprompttext, sizeof(saveprompttext)); - char temptext[500]; - sprintf(temptext, saveprompttext, filename); - switch (MessageBox(hwnd, (LPTSTR)temptext, (LPTSTR)programname, MB_YESNOCANCEL | MB_ICONQUESTION)) + TCHAR programname[20]; + TCHAR saveprompttext[100]; + LoadString(hProgInstance, IDS_PROGRAMNAME, programname, SIZEOF(programname)); + LoadString(hProgInstance, IDS_SAVEPROMPTTEXT, saveprompttext, SIZEOF(saveprompttext)); + TCHAR temptext[500]; + _stprintf(temptext, saveprompttext, filename); + switch (MessageBox(hwnd, temptext, programname, MB_YESNOCANCEL | MB_ICONQUESTION)) { case IDNO: DestroyWindow(hwnd); @@ -319,8 +320,8 @@ { if ((!drawing)||(activeTool<=9)) { - char coordStr[100]; - sprintf(coordStr, "%d, %d", (short)LOWORD(lParam)*1000/zoom, (short)HIWORD(lParam)*1000/zoom); + TCHAR coordStr[100]; + _stprintf(coordStr, _T("%d, %d"), (short)LOWORD(lParam)*1000/zoom, (short)HIWORD(lParam)*1000/zoom); SendMessage(hStatusBar, SB_SETTEXT, 1, (LPARAM)coordStr); } if (drawing) @@ -331,8 +332,8 @@ SendMessage(hImageArea, WM_PAINT, 0, 0); if ((activeTool>=10)||(activeTool==2)) { - char sizeStr[100]; - sprintf(sizeStr, "%d x %d", (short)LOWORD(lParam)*1000/zoom-startX, (short)HIWORD(lParam)*1000/zoom-startY); + TCHAR sizeStr[100]; + _stprintf(sizeStr, _T("%d x %d"), (short)LOWORD(lParam)*1000/zoom-startX, (short)HIWORD(lParam)*1000/zoom-startY); SendMessage(hStatusBar, SB_SETTEXT, 2, (LPARAM)sizeStr); } } @@ -342,15 +343,15 @@ SendMessage(hImageArea, WM_PAINT, 0, 0); if (activeTool>=10) { - char sizeStr[100]; - sprintf(sizeStr, "%d x %d", (short)LOWORD(lParam)*1000/zoom-startX, (short)HIWORD(lParam)*1000/zoom-startY); + TCHAR sizeStr[100]; + _stprintf(sizeStr, _T("%d x %d"), (short)LOWORD(lParam)*1000/zoom-startX, (short)HIWORD(lParam)*1000/zoom-startY); SendMessage(hStatusBar, SB_SETTEXT, 2, (LPARAM)sizeStr); } } } } else { - SendMessage(hStatusBar, SB_SETTEXT, 1, (LPARAM)""); + SendMessage(hStatusBar, SB_SETTEXT, 1, (LPARAM)_T("")); } break;
@@ -362,11 +363,11 @@ case IDM_HELPINFO: { HICON paintIcon = LoadIcon(hProgInstance, MAKEINTRESOURCE(IDI_APPICON)); - char infotitle[100]; - char infotext[200]; - LoadString(hProgInstance, IDS_INFOTITLE, (LPTSTR)infotitle, sizeof(infotitle)); - LoadString(hProgInstance, IDS_INFOTEXT, (LPTSTR)infotext, sizeof(infotext)); - ShellAbout(hMainWnd, (LPTSTR)infotitle, (LPTSTR)infotext, paintIcon); + TCHAR infotitle[100]; + TCHAR infotext[200]; + LoadString(hProgInstance, IDS_INFOTITLE, infotitle, SIZEOF(infotitle)); + LoadString(hProgInstance, IDS_INFOTEXT, infotext, SIZEOF(infotext)); + ShellAbout(hMainWnd, infotitle, infotext, paintIcon); DeleteObject(paintIcon); } break; @@ -388,12 +389,12 @@ { insertReversible(bmNew); updateCanvasAndScrollbars(); - char tempstr[1000]; - char resstr[100]; + TCHAR tempstr[1000]; + TCHAR resstr[100]; CopyMemory(filename, ofn.lpstrFileTitle, sizeof(filename)); CopyMemory(filepathname, ofn.lpstrFileTitle, sizeof(filepathname)); - LoadString(hProgInstance, IDS_WINDOWTITLE, (LPTSTR)resstr, sizeof(resstr)); - sprintf(tempstr, resstr, filename); + LoadString(hProgInstance, IDS_WINDOWTITLE, resstr, SIZEOF(resstr)); + _stprintf(tempstr, resstr, filename); SetWindowText(hMainWnd, tempstr); clearHistory(); isAFile = TRUE; @@ -410,12 +411,12 @@ if (GetSaveFileName(&sfn)!=0) { SaveDIBToFile(hBms[currInd], sfn.lpstrFile, hDrawingDC); - char tempstr[1000]; - char resstr[100]; + TCHAR tempstr[1000]; + TCHAR resstr[100]; CopyMemory(filename, sfn.lpstrFileTitle, sizeof(filename)); CopyMemory(filepathname, sfn.lpstrFileTitle, sizeof(filepathname)); - LoadString(hProgInstance, IDS_WINDOWTITLE, (LPTSTR)resstr, sizeof(resstr)); - sprintf(tempstr, resstr, filename); + LoadString(hProgInstance, IDS_WINDOWTITLE, resstr, SIZEOF(resstr)); + _stprintf(tempstr, resstr, filename); SetWindowText(hMainWnd, tempstr); isAFile = TRUE; }