Author: cwittich Date: Wed Jun 17 01:12:47 2009 New Revision: 41427 URL: http://svn.reactos.org/svn/reactos?rev=41427&view=rev Log: attempt to convert most of this mess into something which at least look like C code
Modified: trunk/reactos/base/applications/paint/dib.c trunk/reactos/base/applications/paint/drawing.c trunk/reactos/base/applications/paint/history.c trunk/reactos/base/applications/paint/main.c trunk/reactos/base/applications/paint/mouse.c trunk/reactos/base/applications/paint/palette.c trunk/reactos/base/applications/paint/selection.c trunk/reactos/base/applications/paint/toolsettings.c trunk/reactos/base/applications/paint/winproc.c Modified: trunk/reactos/base/applications/paint/dib.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/paint/dib.c?rev=41427&r1=41426&r2=41427&view=diff ============================================================================== --- trunk/reactos/base/applications/paint/dib.c [iso-8859-1] (original) +++ trunk/reactos/base/applications/paint/dib.c [iso-8859-1] Wed Jun 17 01:12:47 2009 @@ -46,10 +46,15 @@ void SaveDIBToFile(HBITMAP hbm, LPTSTR name, HDC hdc) { BITMAP bm; - GetObject(hbm, sizeof(BITMAP), &bm); + HANDLE hFile; BITMAPFILEHEADER bf; BITMAPINFOHEADER bi; - int imgDataSize = bm.bmWidthBytes*bm.bmHeight; + int imgDataSize; + int bytesWritten; + + GetObject(hbm, sizeof(BITMAP), &bm); + + imgDataSize = bm.bmWidthBytes*bm.bmHeight; bf.bfType = 0x4d42; bf.bfSize = imgDataSize+52; bf.bfReserved1 = 0; @@ -68,12 +73,11 @@ bi.biClrImportant = 0; int *buffer = HeapAlloc(GetProcessHeap(), HEAP_GENERATE_EXCEPTIONS, imgDataSize); GetDIBits(hdc, hbm, 0, bm.bmHeight, buffer, (LPBITMAPINFO)&bi, DIB_RGB_COLORS); - HANDLE f = CreateFile(name, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_FLAG_SEQUENTIAL_SCAN, NULL); - int bytesWritten; - WriteFile(f, &bf, 14, (LPDWORD)&bytesWritten, NULL); - WriteFile(f, &bi, 40, (LPDWORD)&bytesWritten, NULL); - WriteFile(f, buffer, imgDataSize, (LPDWORD)&bytesWritten, NULL); - CloseHandle(f); + hFile = CreateFile(name, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_FLAG_SEQUENTIAL_SCAN, NULL); + WriteFile(hFile, &bf, 14, (LPDWORD)&bytesWritten, NULL); + WriteFile(hFile, &bi, 40, (LPDWORD)&bytesWritten, NULL); + WriteFile(hFile, buffer, imgDataSize, (LPDWORD)&bytesWritten, NULL); + CloseHandle(hFile); HeapFree(GetProcessHeap(), 0, buffer); } Modified: trunk/reactos/base/applications/paint/drawing.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/paint/drawing.c?rev=41427&r1=41426&r2=41427&view=diff ============================================================================== --- trunk/reactos/base/applications/paint/drawing.c [iso-8859-1] (original) +++ trunk/reactos/base/applications/paint/drawing.c [iso-8859-1] Wed Jun 17 01:12:47 2009 @@ -22,12 +22,13 @@ void Rect(HDC hdc, short x1, short y1, short x2, short y2, int fg, int bg, int thickness, BOOL filled) { + HBRUSH oldBrush; + LOGBRUSH logbrush; HPEN oldPen = SelectObject(hdc, CreatePen(PS_SOLID, thickness, fg)); - LOGBRUSH logbrush; if (filled) logbrush.lbStyle = BS_SOLID; else logbrush.lbStyle = BS_HOLLOW; logbrush.lbColor = bg; logbrush.lbHatch = 0; - HBRUSH oldBrush = SelectObject(hdc, CreateBrushIndirect(&logbrush)); + oldBrush = SelectObject(hdc, CreateBrushIndirect(&logbrush)); Rectangle(hdc, x1, y1, x2, y2); DeleteObject(SelectObject(hdc, oldBrush)); DeleteObject(SelectObject(hdc, oldPen)); @@ -35,12 +36,13 @@ void Ellp(HDC hdc, short x1, short y1, short x2, short y2, int fg, int bg, int thickness, BOOL filled) { + HBRUSH oldBrush; + LOGBRUSH logbrush; HPEN oldPen = SelectObject(hdc, CreatePen(PS_SOLID, thickness, fg)); - LOGBRUSH logbrush; if (filled) logbrush.lbStyle = BS_SOLID; else logbrush.lbStyle = BS_HOLLOW; logbrush.lbColor = bg; logbrush.lbHatch = 0; - HBRUSH oldBrush = SelectObject(hdc, CreateBrushIndirect(&logbrush)); + oldBrush = SelectObject(hdc, CreateBrushIndirect(&logbrush)); Ellipse(hdc, x1, y1, x2, y2); DeleteObject(SelectObject(hdc, oldBrush)); DeleteObject(SelectObject(hdc, oldPen)); @@ -48,12 +50,13 @@ void RRect(HDC hdc, short x1, short y1, short x2, short y2, int fg, int bg, int thickness, BOOL filled) { + LOGBRUSH logbrush; + HBRUSH oldBrush; HPEN oldPen = SelectObject(hdc, CreatePen(PS_SOLID, thickness, fg)); - LOGBRUSH logbrush; if (filled) logbrush.lbStyle = BS_SOLID; else logbrush.lbStyle = BS_HOLLOW; logbrush.lbColor = bg; logbrush.lbHatch = 0; - HBRUSH oldBrush = SelectObject(hdc, CreateBrushIndirect(&logbrush)); + oldBrush = SelectObject(hdc, CreateBrushIndirect(&logbrush)); RoundRect(hdc, x1, y1, x2, y2, 16, 16); DeleteObject(SelectObject(hdc, oldBrush)); DeleteObject(SelectObject(hdc, oldPen)); @@ -68,9 +71,10 @@ void Erase(HDC hdc, short x1, short y1, short x2, short y2, int color, int radius) { - HPEN oldPen = SelectObject(hdc, CreatePen(PS_SOLID, 1, color)); + short a; + HPEN oldPen; HBRUSH oldBrush = SelectObject(hdc, CreateSolidBrush(color)); - short a; + oldPen = SelectObject(hdc, CreatePen(PS_SOLID, 1, color)); for (a=0; a<=100; a++) Rectangle(hdc, (x1*(100-a)+x2*a)/100-radius+1, (y1*(100-a)+y2*a)/100-radius+1, (x1*(100-a)+x2*a)/100+radius+1, (y1*(100-a)+y2*a)/100+radius+1); DeleteObject(SelectObject(hdc, oldBrush)); @@ -165,12 +169,13 @@ void RectSel(HDC hdc, short x1, short y1, short x2, short y2) { + HBRUSH oldBrush; + LOGBRUSH logbrush; HPEN oldPen = SelectObject(hdc, CreatePen(PS_DOT, 1, 0x00000000)); - LOGBRUSH logbrush; logbrush.lbStyle = BS_HOLLOW; logbrush.lbColor = 0; logbrush.lbHatch = 0; - HBRUSH oldBrush = SelectObject(hdc, CreateBrushIndirect(&logbrush)); + oldBrush = SelectObject(hdc, CreateBrushIndirect(&logbrush)); Rectangle(hdc, x1, y1, x2, y2); DeleteObject(SelectObject(hdc, oldBrush)); DeleteObject(SelectObject(hdc, oldPen)); @@ -178,12 +183,13 @@ void SelectionFrame(HDC hdc, int x1, int y1, int x2, int y2) { + HBRUSH oldBrush; + LOGBRUSH logbrush; HPEN oldPen = SelectObject(hdc, CreatePen(PS_DOT, 1, 0x00000000)); - LOGBRUSH logbrush; logbrush.lbStyle = BS_HOLLOW; logbrush.lbColor = 0; logbrush.lbHatch = 0; - HBRUSH oldBrush = SelectObject(hdc, CreateBrushIndirect(&logbrush)); + oldBrush = SelectObject(hdc, CreateBrushIndirect(&logbrush)); Rectangle(hdc, x1, y1, x2, y2); DeleteObject(SelectObject(hdc, oldBrush)); DeleteObject(SelectObject(hdc, oldPen)); Modified: trunk/reactos/base/applications/paint/history.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/paint/history.c?rev=41427&r1=41426&r2=41427&view=diff ============================================================================== --- trunk/reactos/base/applications/paint/history.c [iso-8859-1] (original) +++ trunk/reactos/base/applications/paint/history.c [iso-8859-1] Wed Jun 17 01:12:47 2009 @@ -93,6 +93,10 @@ void cropReversible(int x, int y)//FIXME: This function is broken { + HBITMAP oldBitmap; + HPEN oldPen; + HBRUSH oldBrush; + SelectObject(hDrawingDC, hBms[currInd]); DeleteObject(hBms[(currInd+1)%4]); hBms[(currInd+1)%4] = CreateDIBWithProperties(x, y); @@ -100,9 +104,9 @@ if (undoSteps<3) undoSteps++; redoSteps = 0; - HBITMAP oldBitmap = SelectObject(hSelDC, hBms[currInd]); - HPEN oldPen = SelectObject(hSelDC, CreatePen(PS_SOLID, 1, bgColor)); - HBRUSH oldBrush = SelectObject(hSelDC, CreateSolidBrush(bgColor)); + oldBitmap = SelectObject(hSelDC, hBms[currInd]); + oldPen = SelectObject(hSelDC, CreatePen(PS_SOLID, 1, bgColor)); + oldBrush = SelectObject(hSelDC, CreateSolidBrush(bgColor)); Rectangle(hSelDC, 0, 0, x, y); DeleteObject(SelectObject(hSelDC, oldBrush)); DeleteObject(SelectObject(hSelDC, oldPen)); Modified: trunk/reactos/base/applications/paint/main.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/paint/main.c?rev=41427&r1=41426&r2=41427&view=diff ============================================================================== --- trunk/reactos/base/applications/paint/main.c [iso-8859-1] (original) +++ trunk/reactos/base/applications/paint/main.c [iso-8859-1] Wed Jun 17 01:12:47 2009 @@ -104,15 +104,39 @@ int WINAPI _tWinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPTSTR lpszArgument, int nFunsterStil) { - hProgInstance = hThisInstance; HWND hwnd; /* This is the handle for our window */ MSG messages; /* Here messages to the application are saved */ - - // Necessary + WNDCLASSEX wclScroll; + WNDCLASSEX wincl; + WNDCLASSEX wclPal; + WNDCLASSEX wclSettings; + WNDCLASSEX wclSelection; + TCHAR progtitle[1000]; + TCHAR resstr[100]; + HMENU menu; + HWND hToolbar; + HIMAGELIST hImageList; + HANDLE haccel; + HBITMAP tempBm; + int i; + TCHAR tooltips[16][30]; + TCHAR *c; + TCHAR sfnFilename[1000]; + TCHAR sfnFiletitle[256]; + TCHAR sfnFilter[1000]; + TCHAR ofnFilename[1000]; + TCHAR ofnFiletitle[256]; + TCHAR ofnFilter[1000]; + int custColors[16] = + {0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, + 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff}; + + hProgInstance = hThisInstance; + + /* Necessary */ InitCommonControls(); - //initializing and registering the window class used for the main window - WNDCLASSEX wincl; + /* initializing and registering the window class used for the main window */ wincl.hInstance = hThisInstance; wincl.lpszClassName = _T("WindowsApp"); wincl.lpfnWndProc = WindowProcedure; @@ -127,9 +151,7 @@ wincl.hbrBackground = GetSysColorBrush(COLOR_BTNFACE); RegisterClassEx (&wincl); - // initializing and registering the window class used for the scroll box - - WNDCLASSEX wclScroll; + /* initializing and registering the window class used for the scroll box */ wclScroll.hInstance = hThisInstance; wclScroll.lpszClassName = _T("Scrollbox"); wclScroll.lpfnWndProc = WindowProcedure; @@ -144,9 +166,7 @@ wclScroll.hbrBackground = GetSysColorBrush(COLOR_APPWORKSPACE); RegisterClassEx (&wclScroll); - // initializing and registering the window class used for the palette window - - WNDCLASSEX wclPal; + /* initializing and registering the window class used for the palette window */ wclPal.hInstance = hThisInstance; wclPal.lpszClassName = _T("Palette"); wclPal.lpfnWndProc = PalWinProc; @@ -161,9 +181,7 @@ wclPal.hbrBackground = GetSysColorBrush(COLOR_BTNFACE); RegisterClassEx (&wclPal); - // initializing and registering the window class for the settings window - - WNDCLASSEX wclSettings; + /* initializing and registering the window class for the settings window */ wclSettings.hInstance = hThisInstance; wclSettings.lpszClassName = _T("ToolSettings"); wclSettings.lpfnWndProc = SettingsWinProc; @@ -178,9 +196,7 @@ wclSettings.hbrBackground = GetSysColorBrush(COLOR_BTNFACE); RegisterClassEx (&wclSettings); - // initializing and registering the window class for the selection frame - - WNDCLASSEX wclSelection; + /* initializing and registering the window class for the selection frame */ wclSelection.hInstance = hThisInstance; wclSelection.lpszClassName = _T("Selection"); wclSelection.lpfnWndProc = SelectionWinProc; @@ -196,24 +212,21 @@ RegisterClassEx (&wclSelection); 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 + /* create main window */ hwnd = CreateWindowEx (0, _T("WindowsApp"), progtitle, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 544, 375, HWND_DESKTOP, NULL, hThisInstance, NULL); hMainWnd = hwnd; - // loading and setting the window menu from resource - HMENU menu; + /* loading and setting the window menu from resource */ menu = LoadMenu(hThisInstance, MAKEINTRESOURCE(ID_MENU)); SetMenu(hwnd, menu); - HANDLE haccel = LoadAccelerators(hThisInstance, MAKEINTRESOURCE(800)); - - // preloading the draw transparent/nontransparent icons for later use + haccel = LoadAccelerators(hThisInstance, MAKEINTRESOURCE(800)); + + /* preloading the draw transparent/nontransparent icons for later use */ hNontranspIcon = LoadImage(hThisInstance, MAKEINTRESOURCE(IDI_NONTRANSPARENT), IMAGE_ICON, 40, 30, LR_DEFAULTCOLOR); hTranspIcon = LoadImage(hThisInstance, MAKEINTRESOURCE(IDI_TRANSPARENT), IMAGE_ICON, 40, 30, LR_DEFAULTCOLOR); @@ -225,19 +238,17 @@ 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 - - - // FIXME: Unintentionally there is a line above the tool bar. To prevent cropping of the buttons height has been increased from 200 to 205 - HWND hToolbar = CreateWindowEx(0, TOOLBARCLASSNAME, NULL, WS_CHILD | WS_VISIBLE | CCS_NOPARENTALIGN | CCS_VERT | CCS_NORESIZE | TBSTYLE_TOOLTIPS, 3, 3, 50, 205, hwnd, NULL, hThisInstance, NULL); - HIMAGELIST hImageList = ImageList_Create(16, 16, ILC_COLOR24 | ILC_MASK, 16, 0); + /* creating the 16 bitmap radio buttons and setting the bitmap */ + + + /* FIXME: Unintentionally there is a line above the tool bar. To prevent cropping of the buttons height has been increased from 200 to 205 */ + hToolbar = CreateWindowEx(0, TOOLBARCLASSNAME, NULL, WS_CHILD | WS_VISIBLE | CCS_NOPARENTALIGN | CCS_VERT | CCS_NORESIZE | TBSTYLE_TOOLTIPS, 3, 3, 50, 205, hwnd, NULL, hThisInstance, NULL); + hImageList = ImageList_Create(16, 16, ILC_COLOR24 | ILC_MASK, 16, 0); SendMessage(hToolbar, TB_SETIMAGELIST, 0, (LPARAM)hImageList); - HBITMAP tempBm = LoadImage(hThisInstance, MAKEINTRESOURCE(IDB_TOOLBARICONS), IMAGE_BITMAP, 256, 16, 0); + tempBm = LoadImage(hThisInstance, MAKEINTRESOURCE(IDB_TOOLBARICONS), IMAGE_BITMAP, 256, 16, 0); ImageList_AddMasked(hImageList, tempBm, 0xff00ff); DeleteObject(tempBm); SendMessage(hToolbar, TB_BUTTONSTRUCTSIZE, sizeof(TBBUTTON), 0); - int i; - TCHAR tooltips[16][30]; for (i=0; i<16; i++) { int wrapnow = 0; @@ -246,35 +257,35 @@ TBBUTTON tbbutton = { i, ID_FREESEL + i, TBSTATE_ENABLED | wrapnow, TBSTYLE_CHECKGROUP, {0}, 0, (INT_PTR)tooltips[i] }; SendMessage(hToolbar, TB_ADDBUTTONS, 1, (LPARAM)&tbbutton); } - // SendMessage(hToolbar, TB_SETROWS, MAKEWPARAM(8, FALSE), (LPARAM)NULL); + /* SendMessage(hToolbar, TB_SETROWS, MAKEWPARAM(8, FALSE), (LPARAM)NULL); */ SendMessage(hToolbar, TB_CHECKBUTTON, ID_PEN, MAKELONG(TRUE, 0)); SendMessage(hToolbar, TB_SETMAXTEXTROWS, 0, 0); SendMessage(hToolbar, TB_SETBUTTONSIZE, 0, MAKELONG(25, 25)); - // SendMessage(hToolbar, TB_AUTOSIZE, 0, 0); - - - - - // creating the tool settings child window + /* SendMessage(hToolbar, TB_AUTOSIZE, 0, 0); */ + + + + + /* creating the tool settings child window */ hToolSettings = CreateWindowEx(0, _T("ToolSettings"), _T(""), WS_CHILD | WS_VISIBLE, 7, 210, 42, 140, hwnd, NULL, hThisInstance, NULL); - // creating the palette child window + /* creating the palette child window */ hPalWin = CreateWindowEx(0, _T("Palette"), _T(""), WS_CHILD | WS_VISIBLE, 56, 9, 255, 32, hwnd, NULL, hThisInstance, NULL); - // creating the scroll box + /* creating the scroll box */ 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 + /* creating the status bar */ 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, _T("Scrollbox"), _T(""), WS_CHILD | WS_VISIBLE, 0, 0, 500, 500, hScrollbox, NULL, hThisInstance, NULL); - // create selection window (initially hidden) + /* create selection window (initially hidden) */ 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 + /* creating the window inside the scroll box, on which the image in hDrawingDC's bitmap is drawn */ hImageArea = CreateWindowEx (0, _T("Scrollbox"), _T(""), WS_CHILD | WS_VISIBLE, 3, 3, imgXRes, imgYRes, hScrlClient, NULL, hThisInstance, NULL); hDrawingDC = CreateCompatibleDC(GetDC(hImageArea)); @@ -286,10 +297,7 @@ SelectObject(hDrawingDC, hBms[0]); Rectangle(hDrawingDC, 0-1, 0-1, imgXRes+1, imgYRes+1); - // initializing the CHOOSECOLOR structure for use with ChooseColor - int custColors[16] = - {0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, - 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff}; + /* initializing the CHOOSECOLOR structure for use with ChooseColor */ choosecolor.lStructSize = sizeof(CHOOSECOLOR); choosecolor.hwndOwner = hwnd; choosecolor.hInstance = NULL; @@ -300,13 +308,8 @@ choosecolor.lpfnHook = NULL; choosecolor.lpTemplateName = NULL; - TCHAR *c; - - // initializing the OPENFILENAME structure for use with GetOpenFileName and GetSaveFileName - TCHAR ofnFilename[1000]; + /* initializing the OPENFILENAME structure for use with GetOpenFileName and GetSaveFileName */ CopyMemory(ofnFilename, filename, sizeof(filename)); - 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)); @@ -320,10 +323,7 @@ ofn.nMaxFileTitle = SIZEOF(ofnFiletitle); ofn.Flags = OFN_HIDEREADONLY; - TCHAR sfnFilename[1000]; CopyMemory(sfnFilename, filename, sizeof(filename)); - 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)); @@ -338,7 +338,7 @@ sfn.Flags = OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY; - // by moving the window, the things in WM_SIZE are done + /* by moving the window, the things in WM_SIZE are done */ MoveWindow(hwnd, 100, 100, 600, 450, TRUE); /* Make the window visible on the screen */ Modified: trunk/reactos/base/applications/paint/mouse.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/paint/mouse.c?rev=41427&r1=41426&r2=41427&view=diff ============================================================================== --- trunk/reactos/base/applications/paint/mouse.c [iso-8859-1] (original) +++ trunk/reactos/base/applications/paint/mouse.c [iso-8859-1] Wed Jun 17 01:12:47 2009 @@ -59,9 +59,11 @@ { case 2: { + short tempX; + short tempY; resetToU1(); - short tempX = max(0, min(x, imgXRes)); - short tempY = max(0, min(y, imgYRes)); + tempX = max(0, min(x, imgXRes)); + tempY = max(0, min(y, imgYRes)); rectSel_dest[0] = rectSel_src[0] = min(startX, tempX); rectSel_dest[1] = rectSel_src[1] = min(startY, tempY); rectSel_dest[2] = rectSel_src[2] = max(startX, tempX)-min(startX, tempX); Modified: trunk/reactos/base/applications/paint/palette.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/paint/palette.c?rev=41427&r1=41426&r2=41427&view=diff ============================================================================== --- trunk/reactos/base/applications/paint/palette.c [iso-8859-1] (original) +++ trunk/reactos/base/applications/paint/palette.c [iso-8859-1] Wed Jun 17 01:12:47 2009 @@ -19,14 +19,16 @@ { case WM_PAINT: { - DefWindowProc (hwnd, message, wParam, lParam); - HDC hdc = GetDC(hwnd); - HPEN oldPen; - HBRUSH oldBrush; int i; long rectang[4] = {0, 0, 31, 32}; int a; int b; + HDC hdc = GetDC(hwnd); + HPEN oldPen; + HBRUSH oldBrush; + + DefWindowProc (hwnd, message, wParam, lParam); + for (b=2; b<30; b++) for (a=2; a<29; a++) if ((a+b)%2==1) SetPixel(hdc, a, b, GetSysColor(COLOR_BTNHILIGHT)); DrawEdge(hdc, (LPRECT)&rectang, EDGE_RAISED, BF_TOPLEFT); DrawEdge(hdc, (LPRECT)&rectang, BDR_SUNKENOUTER, BF_TOPLEFT|BF_BOTTOMRIGHT); Modified: trunk/reactos/base/applications/paint/selection.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/paint/selection.c?rev=41427&r1=41426&r2=41427&view=diff ============================================================================== --- trunk/reactos/base/applications/paint/selection.c [iso-8859-1] (original) +++ trunk/reactos/base/applications/paint/selection.c [iso-8859-1] Wed Jun 17 01:12:47 2009 @@ -28,8 +28,8 @@ { if (!moving) { + HDC hdc=GetDC(hwnd); DefWindowProc (hwnd, message, wParam, lParam); - HDC hdc=GetDC(hwnd); SelectionFrame(hdc, 1, 1, rectSel_dest[2]*zoom/1000+5, rectSel_dest[3]*zoom/1000+5); ReleaseDC(hwnd, hdc); } Modified: trunk/reactos/base/applications/paint/toolsettings.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/paint/toolsettings.c?rev=41427&r1=41426&r2=41427&view=diff ============================================================================== --- trunk/reactos/base/applications/paint/toolsettings.c [iso-8859-1] (original) +++ trunk/reactos/base/applications/paint/toolsettings.c [iso-8859-1] Wed Jun 17 01:12:47 2009 @@ -20,13 +20,13 @@ { case WM_PAINT: { + HDC hdc = GetDC(hwnd); + int rectang[4] = {0, 0, 42, 66}; + int rectang2[4] = {0, 70, 42, 136}; + DefWindowProc (hwnd, message, wParam, lParam); - HDC hdc = GetDC(hwnd); - - int rectang[4] = {0, 0, 42, 66}; DrawEdge(hdc, (LPRECT)&rectang, BDR_SUNKENOUTER, BF_RECT | BF_MIDDLE); - int rectang2[4] = {0, 70, 42, 136}; if (activeTool>=13) DrawEdge(hdc, (LPRECT)&rectang2, BDR_SUNKENOUTER, BF_RECT | BF_MIDDLE); else @@ -64,11 +64,11 @@ break; case 8: { + int i; HPEN oldPen = SelectObject(hdc, CreatePen(PS_NULL, 0, 0)); SelectObject(hdc, GetSysColorBrush(COLOR_HIGHLIGHT)); Rectangle(hdc, brushStyle%3*13+2, brushStyle/3*15+2, brushStyle%3*13+15, brushStyle/3*15+17); DeleteObject(SelectObject(hdc, oldPen)); - int i; for (i=0; i<12; i++) if (i==brushStyle) Brush(hdc, i%3*13+7, i/3*15+8, i%3*13+7, i/3*15+8, GetSysColor(COLOR_HIGHLIGHTTEXT), i); Modified: trunk/reactos/base/applications/paint/winproc.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/paint/winproc.c?rev=41427&r1=41426&r2=41427&view=diff ============================================================================== --- trunk/reactos/base/applications/paint/winproc.c [iso-8859-1] (original) +++ trunk/reactos/base/applications/paint/winproc.c [iso-8859-1] Wed Jun 17 01:12:47 2009 @@ -64,9 +64,9 @@ { TCHAR programname[20]; TCHAR saveprompttext[100]; + TCHAR temptext[500]; 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)) { @@ -157,11 +157,12 @@ if ((hwnd==hImageArea)||(hwnd==hScrollbox)) { long clientRectScrollbox[4]; + long clientRectImageArea[4]; + SCROLLINFO horzScroll; + SCROLLINFO vertScroll; GetClientRect(hScrollbox, (LPRECT)&clientRectScrollbox); - long clientRectImageArea[4]; GetClientRect(hImageArea, (LPRECT)&clientRectImageArea); MoveWindow(hScrlClient, 0, 0, max(clientRectImageArea[2]+6, clientRectScrollbox[2]), max(clientRectImageArea[3]+6, clientRectScrollbox[3]), TRUE); - SCROLLINFO horzScroll; horzScroll.cbSize = sizeof(SCROLLINFO); horzScroll.fMask = SIF_PAGE | SIF_RANGE; horzScroll.nMax = 10000; @@ -171,7 +172,6 @@ horzScroll.nTrackPos = 0; SetScrollInfo(hScrollbox, SB_HORZ, &horzScroll, TRUE); GetClientRect(hScrollbox, (LPRECT)clientRectScrollbox); - SCROLLINFO vertScroll; vertScroll.cbSize = sizeof(SCROLLINFO); vertScroll.fMask = SIF_PAGE | SIF_RANGE; vertScroll.nMax = 10000; @@ -388,10 +388,10 @@ HBITMAP bmNew = (HBITMAP)LoadDIBFromFile(ofn.lpstrFile); if (bmNew!=NULL) { + TCHAR tempstr[1000]; + TCHAR resstr[100]; insertReversible(bmNew); updateCanvasAndScrollbars(); - TCHAR tempstr[1000]; - TCHAR resstr[100]; CopyMemory(filename, ofn.lpstrFileTitle, sizeof(filename)); CopyMemory(filepathname, ofn.lpstrFileTitle, sizeof(filepathname)); LoadString(hProgInstance, IDS_WINDOWTITLE, resstr, SIZEOF(resstr)); @@ -411,9 +411,9 @@ case IDM_FILESAVEAS: if (GetSaveFileName(&sfn)!=0) { - SaveDIBToFile(hBms[currInd], sfn.lpstrFile, hDrawingDC); TCHAR tempstr[1000]; TCHAR resstr[100]; + SaveDIBToFile(hBms[currInd], sfn.lpstrFile, hDrawingDC); CopyMemory(filename, sfn.lpstrFileTitle, sizeof(filename)); CopyMemory(filepathname, sfn.lpstrFileTitle, sizeof(filepathname)); LoadString(hProgInstance, IDS_WINDOWTITLE, resstr, SIZEOF(resstr)); @@ -484,9 +484,10 @@ break; case IDM_IMAGEINVERTCOLORS: { + RECT tempRect; newReversible(); - int tempRect[4] = {0, 0, imgXRes, imgYRes}; - InvertRect(hDrawingDC, (LPRECT)tempRect); + SetRect(&tempRect, 0, 0, imgXRes, imgYRes); + InvertRect(hDrawingDC, &tempRect); SendMessage(hImageArea, WM_PAINT, 0, 0); } break;