From 3404823d074a08b8c0824b505db16168f7e66201 Mon Sep 17 00:00:00 2001
From: LAPTOP-SNT8I5JK\Boounion <Chenluhua@qq.com>
Date: 星期一, 09 六月 2025 09:49:10 +0800
Subject: [PATCH] Merge branch 'clh'
---
SourceCode/Bond/Servo/ServoMemDC.cpp | 40 ++++++++++++++++++++++++++++++++++++++++
1 files changed, 40 insertions(+), 0 deletions(-)
diff --git a/SourceCode/Bond/Servo/ServoMemDC.cpp b/SourceCode/Bond/Servo/ServoMemDC.cpp
new file mode 100644
index 0000000..d22e949
--- /dev/null
+++ b/SourceCode/Bond/Servo/ServoMemDC.cpp
@@ -0,0 +1,40 @@
+#include "stdafx.h"
+#include "ServoMemDC.h"
+
+CServoMemDC::CServoMemDC(CDC* pDC, const CRect* pRect)
+ : CDC(), m_pOldBitmap(nullptr), m_pDC(pDC), m_bMemDC(FALSE)
+{
+ ASSERT(pDC != nullptr);
+
+ if (pRect == nullptr)
+ pDC->GetClipBox(&m_rect);
+ else
+ m_rect = *pRect;
+
+ if (CreateCompatibleDC(pDC)) {
+ m_bMemDC = TRUE;
+ m_bitmap.CreateCompatibleBitmap(pDC, m_rect.Width(), m_rect.Height());
+ m_pOldBitmap = SelectObject(&m_bitmap);
+ SetWindowOrg(m_rect.left, m_rect.top);
+ }
+}
+
+CServoMemDC::~CServoMemDC()
+{
+ if (m_bMemDC) {
+ // 将内存 DC 拷贝回原始窗口 DC
+ m_pDC->BitBlt(m_rect.left, m_rect.top, m_rect.Width(), m_rect.Height(),
+ this, m_rect.left, m_rect.top, SRCCOPY);
+ SelectObject(m_pOldBitmap);
+ }
+}
+
+CServoMemDC* CServoMemDC::operator->()
+{
+ return this;
+}
+
+CServoMemDC::operator CDC* ()
+{
+ return this;
+}
\ No newline at end of file
--
Gitblit v1.9.3