Synchronize with trunk r58457.
[reactos.git] / 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)
                     {