From acf1233799ae959bb55173b442cffdbb754a1f29 Mon Sep 17 00:00:00 2001 From: Dmitry Gorbachev Date: Wed, 27 May 2009 12:03:18 +0000 Subject: [PATCH] Fix some bugs in Paint. svn path=/trunk/; revision=41141 --- reactos/base/applications/paint/dialogs.c | 3 ++ reactos/base/applications/paint/dib.c | 6 +-- reactos/base/applications/paint/dib.h | 4 +- reactos/base/applications/paint/history.c | 2 + reactos/base/applications/paint/main.c | 46 +++++++++---------- reactos/base/applications/paint/mouse.c | 3 ++ reactos/base/applications/paint/selection.c | 3 ++ .../base/applications/paint/toolsettings.c | 1 + reactos/base/applications/paint/winproc.c | 35 +++++++------- 9 files changed, 59 insertions(+), 44 deletions(-) diff --git a/reactos/base/applications/paint/dialogs.c b/reactos/base/applications/paint/dialogs.c index c81adc38c7b..a5592dcfea7 100644 --- a/reactos/base/applications/paint/dialogs.c +++ b/reactos/base/applications/paint/dialogs.c @@ -59,6 +59,7 @@ LRESULT CALLBACK MRDlgWinProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lP default: return FALSE; } + return TRUE; } int mirrorRotateDlg() @@ -93,6 +94,7 @@ LRESULT CALLBACK ATTDlgWinProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM l default: return FALSE; } + return TRUE; } int attributesDlg() @@ -125,6 +127,7 @@ LRESULT CALLBACK CHSIZEDlgWinProc (HWND hwnd, UINT message, WPARAM wParam, LPARA default: return FALSE; } + return TRUE; } int changeSizeDlg() diff --git a/reactos/base/applications/paint/dib.c b/reactos/base/applications/paint/dib.c index 6f4411096a8..ba6f8f0e630 100644 --- a/reactos/base/applications/paint/dib.c +++ b/reactos/base/applications/paint/dib.c @@ -43,7 +43,7 @@ int GetDIBHeight(HBITMAP hbm) return bm.bmHeight; } -void SaveDIBToFile(HBITMAP hbm, char name[], HDC hdc) +void SaveDIBToFile(HBITMAP hbm, LPSTR name, HDC hdc) { BITMAP bm; GetObject(hbm, sizeof(BITMAP), &bm); @@ -77,7 +77,7 @@ void SaveDIBToFile(HBITMAP hbm, char name[], HDC hdc) HeapFree(GetProcessHeap(), 0, buffer); } -HBITMAP LoadDIBFromFile(char name[]) +HBITMAP LoadDIBFromFile(LPSTR name) { HBITMAP bm; BITMAPFILEHEADER bfh; @@ -88,7 +88,7 @@ HBITMAP LoadDIBFromFile(char name[]) ReadFile(f, &bfh, 14, (LPDWORD)&bytesRead, NULL); if (bfh.bfType!=0x4d42) { - fclose(f); + CloseHandle(f); return NULL; } bi = HeapAlloc(GetProcessHeap(), HEAP_GENERATE_EXCEPTIONS, bfh.bfOffBits-14); diff --git a/reactos/base/applications/paint/dib.h b/reactos/base/applications/paint/dib.h index a940bde3bc4..9f1c077066f 100644 --- a/reactos/base/applications/paint/dib.h +++ b/reactos/base/applications/paint/dib.h @@ -12,6 +12,6 @@ int GetDIBWidth(HBITMAP hbm); int GetDIBHeight(HBITMAP hbm); -void SaveDIBToFile(HBITMAP hbm, char name[], HDC hdc); +void SaveDIBToFile(HBITMAP hbm, LPSTR name, HDC hdc); -HBITMAP LoadDIBFromFile(char name[]); +HBITMAP LoadDIBFromFile(LPSTR name); diff --git a/reactos/base/applications/paint/history.c b/reactos/base/applications/paint/history.c index 7d654749f01..70057b237c3 100644 --- a/reactos/base/applications/paint/history.c +++ b/reactos/base/applications/paint/history.c @@ -15,6 +15,8 @@ /* FUNCTIONS ********************************************************/ +extern void updateCanvasAndScrollbars(void); + void setImgXYRes(int x, int y) { if ((imgXRes!=x)||(imgYRes!=y)) diff --git a/reactos/base/applications/paint/main.c b/reactos/base/applications/paint/main.c index 739e3705e5c..99c4b73c48b 100644 --- a/reactos/base/applications/paint/main.c +++ b/reactos/base/applications/paint/main.c @@ -194,11 +194,11 @@ int WINAPI WinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpsz wclSelection.hbrBackground = NULL;//GetSysColorBrush(COLOR_BTNFACE); RegisterClassEx (&wclSelection); - LoadString(hThisInstance, IDS_DEFAULTFILENAME, (LPTSTR)&filename, 256); + LoadString(hThisInstance, IDS_DEFAULTFILENAME, (LPTSTR)filename, sizeof(filename)); char progtitle[1000]; char resstr[100]; - LoadString(hThisInstance, IDS_WINDOWTITLE, (LPTSTR)&resstr, 100); - sprintf(progtitle, resstr, &filename); + LoadString(hThisInstance, IDS_WINDOWTITLE, (LPTSTR)resstr, sizeof(resstr)); + sprintf(progtitle, resstr, filename); // create main window @@ -240,9 +240,9 @@ int WINAPI WinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpsz 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); - TBBUTTON tbbutton = {i, (HMENU)(ID_FREESEL+i), TBSTATE_ENABLED | wrapnow, TBSTYLE_CHECKGROUP, {0}, 0, &tooltips[i]}; + if (i % 2 == 1) wrapnow = TBSTATE_WRAP; + LoadString(hThisInstance, IDS_TOOLTIP1 + i, (LPTSTR)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); } // SendMessage(hToolbar, TB_SETROWS, MAKEWPARAM(8, FALSE), (LPARAM)NULL); @@ -299,41 +299,41 @@ int WINAPI WinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpsz choosecolor.lpfnHook = NULL; choosecolor.lpTemplateName = NULL; - int c; + char *c; // initializing the OPENFILENAME structure for use with GetOpenFileName and GetSaveFileName char ofnFilename[1000]; - CopyMemory(&ofnFilename, &filename, 256); + CopyMemory(ofnFilename, filename, sizeof(filename)); char ofnFiletitle[256]; char ofnFilter[1000]; - LoadString(hThisInstance, IDS_OPENFILTER, (LPTSTR)&ofnFilter, 1000); - for (c=0; c<1000; c++) if (ofnFilter[c]==(char)1) ofnFilter[c] = (char)0; + LoadString(hThisInstance, IDS_OPENFILTER, (LPTSTR)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 = 1000; - ofn.lpstrFileTitle = (LPTSTR)&ofnFiletitle; - ofn.nMaxFileTitle = 256; + ofn.lpstrFilter = (LPCTSTR)ofnFilter; + ofn.lpstrFile = (LPTSTR)ofnFilename; + ofn.nMaxFile = sizeof(ofnFilename); + ofn.lpstrFileTitle = (LPTSTR)ofnFiletitle; + ofn.nMaxFileTitle = sizeof(ofnFiletitle); ofn.Flags = OFN_HIDEREADONLY; char sfnFilename[1000]; - CopyMemory(&sfnFilename, &filename, 256); + CopyMemory(sfnFilename, filename, sizeof(filename)); char sfnFiletitle[256]; char sfnFilter[1000]; - LoadString(hThisInstance, IDS_SAVEFILTER, (LPTSTR)&sfnFilter, 1000); - for (c=0; c<1000; c++) if (sfnFilter[c]==(char)1) sfnFilter[c] = (char)0; + LoadString(hThisInstance, IDS_SAVEFILTER, (LPTSTR)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 = 1000; - sfn.lpstrFileTitle = (LPTSTR)&sfnFiletitle; - sfn.nMaxFileTitle = 256; + sfn.lpstrFilter = (LPCTSTR)sfnFilter; + sfn.lpstrFile = (LPTSTR)sfnFilename; + sfn.nMaxFile = sizeof(sfnFilename); + sfn.lpstrFileTitle = (LPTSTR)sfnFiletitle; + sfn.nMaxFileTitle = sizeof(sfnFiletitle); sfn.Flags = OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY; diff --git a/reactos/base/applications/paint/mouse.c b/reactos/base/applications/paint/mouse.c index 209cf3ae692..1614fb77384 100644 --- a/reactos/base/applications/paint/mouse.c +++ b/reactos/base/applications/paint/mouse.c @@ -9,6 +9,9 @@ /* INCLUDES *********************************************************/ #include "globalvar.h" +#include "dib.h" +#include "drawing.h" +#include "history.h" /* FUNCTIONS ********************************************************/ diff --git a/reactos/base/applications/paint/selection.c b/reactos/base/applications/paint/selection.c index 9cb0245559b..d628a18c661 100644 --- a/reactos/base/applications/paint/selection.c +++ b/reactos/base/applications/paint/selection.c @@ -10,6 +10,9 @@ #include #include "globalvar.h" +#include "drawing.h" +#include "history.h" +#include "mouse.h" /* FUNCTIONS ********************************************************/ diff --git a/reactos/base/applications/paint/toolsettings.c b/reactos/base/applications/paint/toolsettings.c index 4e686eac861..5d0b54664b0 100644 --- a/reactos/base/applications/paint/toolsettings.c +++ b/reactos/base/applications/paint/toolsettings.c @@ -10,6 +10,7 @@ #include #include "globalvar.h" +#include "drawing.h" /* FUNCTIONS ********************************************************/ diff --git a/reactos/base/applications/paint/winproc.c b/reactos/base/applications/paint/winproc.c index 4191029e73b..f5a1241c88d 100644 --- a/reactos/base/applications/paint/winproc.c +++ b/reactos/base/applications/paint/winproc.c @@ -16,7 +16,10 @@ #include "definitions.h" #include "globalvar.h" #include "dialogs.h" +#include "dib.h" +#include "drawing.h" #include "history.h" +#include "mouse.h" /* FUNCTIONS ********************************************************/ @@ -59,11 +62,11 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM { char programname[20]; char saveprompttext[100]; - LoadString(hProgInstance, IDS_PROGRAMNAME, (LPTSTR)&programname, 20); - LoadString(hProgInstance, IDS_SAVEPROMPTTEXT, (LPTSTR)&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)) + switch (MessageBox(hwnd, (LPTSTR)temptext, (LPTSTR)programname, MB_YESNOCANCEL | MB_ICONQUESTION)) { case IDNO: DestroyWindow(hwnd); @@ -361,9 +364,9 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM HICON paintIcon = LoadIcon(hProgInstance, MAKEINTRESOURCE(IDI_APPICON)); char infotitle[100]; char infotext[200]; - LoadString(hProgInstance, IDS_INFOTITLE, (LPTSTR)&infotitle, 100); - LoadString(hProgInstance, IDS_INFOTEXT, (LPTSTR)&infotext, 200); - ShellAbout(hMainWnd, (LPTSTR)&infotitle, (LPTSTR)&infotext, paintIcon); + LoadString(hProgInstance, IDS_INFOTITLE, (LPTSTR)infotitle, sizeof(infotitle)); + LoadString(hProgInstance, IDS_INFOTEXT, (LPTSTR)infotext, sizeof(infotext)); + ShellAbout(hMainWnd, (LPTSTR)infotitle, (LPTSTR)infotext, paintIcon); DeleteObject(paintIcon); } break; @@ -387,10 +390,10 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM updateCanvasAndScrollbars(); char tempstr[1000]; char resstr[100]; - CopyMemory(&filename, ofn.lpstrFileTitle, 256); - CopyMemory(&filepathname, ofn.lpstrFileTitle, 1000); - LoadString(hProgInstance, IDS_WINDOWTITLE, (LPTSTR)&resstr, 100); - sprintf(tempstr, resstr, &filename); + CopyMemory(filename, ofn.lpstrFileTitle, sizeof(filename)); + CopyMemory(filepathname, ofn.lpstrFileTitle, sizeof(filepathname)); + LoadString(hProgInstance, IDS_WINDOWTITLE, (LPTSTR)resstr, sizeof(resstr)); + sprintf(tempstr, resstr, filename); SetWindowText(hMainWnd, tempstr); clearHistory(); isAFile = TRUE; @@ -399,7 +402,7 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM break; case IDM_FILESAVE: if (isAFile) - SaveDIBToFile(hBms[currInd], &filepathname, hDrawingDC); + SaveDIBToFile(hBms[currInd], filepathname, hDrawingDC); else SendMessage(hwnd, WM_COMMAND, IDM_FILESAVEAS, 0); break; @@ -409,10 +412,10 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM SaveDIBToFile(hBms[currInd], sfn.lpstrFile, hDrawingDC); char tempstr[1000]; char resstr[100]; - CopyMemory(&filename, sfn.lpstrFileTitle, 256); - CopyMemory(&filepathname, sfn.lpstrFileTitle, 1000); - LoadString(hProgInstance, IDS_WINDOWTITLE, (LPTSTR)&resstr, 100); - sprintf(tempstr, resstr, &filename); + CopyMemory(filename, sfn.lpstrFileTitle, sizeof(filename)); + CopyMemory(filepathname, sfn.lpstrFileTitle, sizeof(filepathname)); + LoadString(hProgInstance, IDS_WINDOWTITLE, (LPTSTR)resstr, sizeof(resstr)); + sprintf(tempstr, resstr, filename); SetWindowText(hMainWnd, tempstr); isAFile = TRUE; } @@ -503,7 +506,7 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM break; case IDM_IMAGEATTRIBUTES: { - int attrdata[8] = {0, 0, 0, 0, 0, 0, 0, 0}; + //int attrdata[8] = {0, 0, 0, 0, 0, 0, 0, 0}; attributesDlg(); //cropReversible(640, 200); //ZoomTo(zoom); -- 2.17.1