[PAINT]
authorHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Sat, 2 Mar 2013 20:44:09 +0000 (20:44 +0000)
committerHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Sat, 2 Mar 2013 20:44:09 +0000 (20:44 +0000)
- Fix the "grey panel" bug when doing File --> New.
- Add the possibility, when doing File --> New, to save the drawing the user did before actually reset it, and take into account whether he/she cancels the operation in the middle.
Patch by Marco Vaiano, slightly modified by me.

CORE-5642 #resolve #comment Committed in revision r58408. Thanks :)

svn path=/trunk/; revision=58408

reactos/base/applications/mspaint/winproc.c

index c22898c..75fd287 100644 (file)
@@ -710,12 +710,38 @@ WindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
                     SendMessage(hwnd, WM_CLOSE, wParam, lParam);
                     break;
                 case IDM_FILENEW:
-                    ShowWindow(hSelection, SW_HIDE);
-                    clearHistory();
-
-                    Rectangle(hDrawingDC, 0 - 1, 0 - 1, imgXRes + 1, imgYRes + 1);
-                    SendMessage(hImageArea, WM_PAINT, 0, 0);
+                {
+                    BOOL reset = TRUE;
+                    if (!imageSaved)
+                    {
+                        TCHAR programname[20];
+                        TCHAR saveprompttext[100];
+                        TCHAR temptext[500];
+                        LoadString(hProgInstance, IDS_PROGRAMNAME, programname, SIZEOF(programname));
+                        LoadString(hProgInstance, IDS_SAVEPROMPTTEXT, saveprompttext, SIZEOF(saveprompttext));
+                        _stprintf(temptext, saveprompttext, filename);
+                        switch (MessageBox(hwnd, temptext, programname, MB_YESNOCANCEL | MB_ICONQUESTION))
+                        {
+                            case IDNO:
+                                imageSaved = TRUE;
+                                break;
+                            case IDYES:
+                                SendMessage(hwnd, WM_COMMAND, IDM_FILESAVEAS, 0);
+                                break;
+                            case IDCANCEL:
+                                reset = FALSE;
+                                break;
+                        }
+                    }
+                    if (reset && imageSaved)
+                    {
+                        Rectangle(hDrawingDC, 0 - 1, 0 - 1, imgXRes + 1, imgYRes + 1);
+                        SendMessage(hImageArea, WM_PAINT, 0, 0);
+                        updateCanvasAndScrollbars();
+                        clearHistory();
+                    }
                     break;
+                }
                 case IDM_FILEOPEN:
                     if (GetOpenFileName(&ofn) != 0)
                     {