diff --git a/reactos/base/applications/mspaint/history.cpp b/reactos/base/applications/mspaint/history.cpp index 88fc2939cea..abe03bf6318 100644 --- a/reactos/base/applications/mspaint/history.cpp +++ b/reactos/base/applications/mspaint/history.cpp @@ -129,6 +129,11 @@ void ImageModel::Crop(int nWidth, int nHeight, int nOffsetX, int nOffsetY) 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); diff --git a/reactos/base/applications/mspaint/sizebox.cpp b/reactos/base/applications/mspaint/sizebox.cpp index 1ea92d7f6bb..b5709d80bee 100644 --- a/reactos/base/applications/mspaint/sizebox.cpp +++ b/reactos/base/applications/mspaint/sizebox.cpp @@ -12,9 +12,9 @@ /* FUNCTIONS ********************************************************/ -BOOL resizing = FALSE; -short xOrig; -short yOrig; +static BOOL resizing = FALSE; +static short xOrig; +static short yOrig; LRESULT CSizeboxWindow::OnSetCursor(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { @@ -76,8 +76,6 @@ LRESULT CSizeboxWindow::OnLButtonUp(UINT nMsg, WPARAM wParam, LPARAM lParam, BOO { short xRel; short yRel; - ReleaseCapture(); - resizing = FALSE; int imgXRes = imageModel.GetWidth(); int imgYRes = imageModel.GetHeight(); xRel = (GET_X_LPARAM(lParam) - xOrig) * 1000 / toolsModel.GetZoom(); @@ -100,5 +98,13 @@ LRESULT CSizeboxWindow::OnLButtonUp(UINT nMsg, WPARAM wParam, LPARAM lParam, BOO imageModel.Crop(imgXRes + xRel, imgYRes + yRel, 0, 0); SendMessage(hStatusBar, SB_SETTEXT, 2, (LPARAM) _T("")); } + ReleaseCapture(); + resizing = FALSE; + return 0; +} + +LRESULT CSizeboxWindow::OnCancelMode(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) +{ + resizing = FALSE; return 0; } diff --git a/reactos/base/applications/mspaint/sizebox.h b/reactos/base/applications/mspaint/sizebox.h index 8645eb79059..c2624f732e3 100644 --- a/reactos/base/applications/mspaint/sizebox.h +++ b/reactos/base/applications/mspaint/sizebox.h @@ -16,10 +16,12 @@ public: 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); 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); };