Index: reactos/base/applications/mspaint/history.cpp =================================================================== --- reactos/base/applications/mspaint/history.cpp (revision 74717) +++ reactos/base/applications/mspaint/history.cpp (working copy) @@ -129,6 +129,11 @@ int oldWidth = GetWidth(); int oldHeight = GetHeight(); + if (nWidth < 0) + nWidth = 1; + if (nHeight < 0) + nHeight = 1; + SelectObject(hDrawingDC, hBms[currInd]); DeleteObject(hBms[(currInd + 1) % HISTORYSIZE]); hBms[(currInd + 1) % HISTORYSIZE] = CreateDIBWithProperties(nWidth, nHeight); Index: reactos/base/applications/mspaint/sizebox.cpp =================================================================== --- reactos/base/applications/mspaint/sizebox.cpp (revision 74717) +++ reactos/base/applications/mspaint/sizebox.cpp (working copy) @@ -4,6 +4,7 @@ * FILE: base/applications/mspaint/sizebox.cpp * PURPOSE: Window procedure of the size boxes * PROGRAMMERS: Benedikt Freisen + * Katayama Hirofumi MZ */ /* INCLUDES *********************************************************/ @@ -12,10 +13,6 @@ /* FUNCTIONS ********************************************************/ -BOOL resizing = FALSE; -short xOrig; -short yOrig; - LRESULT CSizeboxWindow::OnSetCursor(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { if ((m_hWnd == sizeboxLeftTop.m_hWnd) || (m_hWnd == sizeboxRightBottom.m_hWnd)) @@ -31,9 +28,9 @@ LRESULT CSizeboxWindow::OnLButtonDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { - resizing = TRUE; - xOrig = GET_X_LPARAM(lParam); - yOrig = GET_Y_LPARAM(lParam); + m_resizing = TRUE; + m_xOrig = GET_X_LPARAM(lParam); + m_yOrig = GET_Y_LPARAM(lParam); SetCapture(); return 0; } @@ -40,7 +37,7 @@ LRESULT CSizeboxWindow::OnMouseMove(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { - if (resizing) + if (m_resizing) { CString strSize; short xRel; @@ -47,8 +44,8 @@ short yRel; int imgXRes = imageModel.GetWidth(); int imgYRes = imageModel.GetHeight(); - xRel = (GET_X_LPARAM(lParam) - xOrig) * 1000 / toolsModel.GetZoom(); - yRel = (GET_Y_LPARAM(lParam) - yOrig) * 1000 / toolsModel.GetZoom(); + xRel = (GET_X_LPARAM(lParam) - m_xOrig) * 1000 / toolsModel.GetZoom(); + yRel = (GET_Y_LPARAM(lParam) - m_yOrig) * 1000 / toolsModel.GetZoom(); if (m_hWnd == sizeboxLeftTop.m_hWnd) strSize.Format(_T("%d x %d"), imgXRes - xRel, imgYRes - yRel); if (m_hWnd == sizeboxCenterTop.m_hWnd) @@ -72,16 +69,14 @@ LRESULT CSizeboxWindow::OnLButtonUp(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { - if (resizing) + if (m_resizing) { short xRel; short yRel; - ReleaseCapture(); - resizing = FALSE; int imgXRes = imageModel.GetWidth(); int imgYRes = imageModel.GetHeight(); - xRel = (GET_X_LPARAM(lParam) - xOrig) * 1000 / toolsModel.GetZoom(); - yRel = (GET_Y_LPARAM(lParam) - yOrig) * 1000 / toolsModel.GetZoom(); + xRel = (GET_X_LPARAM(lParam) - m_xOrig) * 1000 / toolsModel.GetZoom(); + yRel = (GET_Y_LPARAM(lParam) - m_yOrig) * 1000 / toolsModel.GetZoom(); if (m_hWnd == sizeboxLeftTop) imageModel.Crop(imgXRes - xRel, imgYRes - yRel, xRel, yRel); if (m_hWnd == sizeboxCenterTop.m_hWnd) @@ -100,5 +95,13 @@ imageModel.Crop(imgXRes + xRel, imgYRes + yRel, 0, 0); SendMessage(hStatusBar, SB_SETTEXT, 2, (LPARAM) _T("")); } + ReleaseCapture(); + m_resizing = FALSE; return 0; } + +LRESULT CSizeboxWindow::OnCancelMode(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) +{ + m_resizing = FALSE; + return 0; +} Index: reactos/base/applications/mspaint/sizebox.h =================================================================== --- reactos/base/applications/mspaint/sizebox.h (revision 74717) +++ reactos/base/applications/mspaint/sizebox.h (working copy) @@ -4,6 +4,7 @@ * FILE: base/applications/mspaint/sizebox.h * PURPOSE: Window procedure of the size boxes * PROGRAMMERS: Benedikt Freisen + * Katayama Hirofumi MZ */ class CSizeboxWindow : public CWindowImpl @@ -16,6 +17,7 @@ MESSAGE_HANDLER(WM_LBUTTONDOWN, OnLButtonDown) MESSAGE_HANDLER(WM_MOUSEMOVE, OnMouseMove) MESSAGE_HANDLER(WM_LBUTTONUP, OnLButtonUp) + MESSAGE_HANDLER(WM_CANCELMODE, OnCancelMode) END_MSG_MAP() LRESULT OnSetCursor(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); @@ -22,4 +24,17 @@ LRESULT OnLButtonDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); LRESULT OnMouseMove(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); LRESULT OnLButtonUp(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); + LRESULT OnCancelMode(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); + + CSizeboxWindow() + { + m_resizing = FALSE; + m_xOrig = 0; + m_yOrig = 0; + } + +protected: + BOOL m_resizing; + short m_xOrig; + short m_yOrig; };