https://git.reactos.org/?p=reactos.git;a=commitdiff;h=96c7fe4ccd336c9cb82bb…
commit 96c7fe4ccd336c9cb82bb800451ec3cd5c17c2f2
Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com>
AuthorDate: Sun Apr 9 09:14:32 2023 +0900
Commit: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com>
CommitDate: Sun Apr 9 09:14:32 2023 +0900
[MSPAINT] Fix Copy and Paste
Call GetSelectionContents in SelectionModel::GetBitmap.
CORE-18920, CORE-18867
---
base/applications/mspaint/selectionmodel.cpp | 4 +++-
base/applications/mspaint/selectionmodel.h | 2 +-
base/applications/mspaint/winproc.cpp | 10 ++++++----
3 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/base/applications/mspaint/selectionmodel.cpp
b/base/applications/mspaint/selectionmodel.cpp
index 59aaa382ac9..56d74ce877e 100644
--- a/base/applications/mspaint/selectionmodel.cpp
+++ b/base/applications/mspaint/selectionmodel.cpp
@@ -349,8 +349,10 @@ void SelectionModel::StretchSkew(int nStretchPercentX, int
nStretchPercentY, int
NotifyRefreshNeeded();
}
-HBITMAP SelectionModel::GetBitmap() const
+HBITMAP SelectionModel::GetBitmap()
{
+ if (m_hbmColor == NULL)
+ GetSelectionContents(imageModel.GetDC());
return m_hbmColor;
}
diff --git a/base/applications/mspaint/selectionmodel.h
b/base/applications/mspaint/selectionmodel.h
index fc1420de7fd..af285e380d8 100644
--- a/base/applications/mspaint/selectionmodel.h
+++ b/base/applications/mspaint/selectionmodel.h
@@ -34,7 +34,7 @@ public:
BOOL TakeOff();
void Landing();
- HBITMAP GetBitmap() const;
+ HBITMAP GetBitmap();
void GetSelectionContents(HDC hDCImage);
void DrawFramePoly(HDC hDCImage);
void DrawBackgroundPoly(HDC hDCImage, COLORREF crBg);
diff --git a/base/applications/mspaint/winproc.cpp
b/base/applications/mspaint/winproc.cpp
index 828bf0855ff..857eedd81ae 100644
--- a/base/applications/mspaint/winproc.cpp
+++ b/base/applications/mspaint/winproc.cpp
@@ -648,10 +648,12 @@ LRESULT CMainWindow::OnCommand(UINT nMsg, WPARAM wParam, LPARAM
lParam, BOOL& bH
canvasWindow.Invalidate(FALSE);
break;
case IDM_EDITCOPY:
- OpenClipboard();
- EmptyClipboard();
- SetClipboardData(CF_BITMAP, CopyDIBImage(selectionModel.GetBitmap()));
- CloseClipboard();
+ if (OpenClipboard())
+ {
+ EmptyClipboard();
+ SetClipboardData(CF_BITMAP, CopyDIBImage(selectionModel.GetBitmap()));
+ CloseClipboard();
+ }
break;
case IDM_EDITCUT:
/* Copy */