From e15e0d2f9305e71cd160f1ddceab93c7889eab20 Mon Sep 17 00:00:00 2001
From: mrDarker <mr.darker@163.com>
Date: 星期四, 05 六月 2025 17:37:33 +0800
Subject: [PATCH] 1. 解决自定义按钮资源泄露问题 2. 增加Slot点击回调和鼠标悬停/点击高亮效果

---
 SourceCode/Bond/Servo/BlButton.cpp |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/SourceCode/Bond/Servo/BlButton.cpp b/SourceCode/Bond/Servo/BlButton.cpp
index 5eb7694..2bddd2b 100644
--- a/SourceCode/Bond/Servo/BlButton.cpp
+++ b/SourceCode/Bond/Servo/BlButton.cpp
@@ -219,8 +219,7 @@
 		hFont = (HFONT)pFont->GetSafeHandle();
 	}
 
-
-	::SelectObject(hDC, hFont);
+	HFONT hOldFont = (HFONT)::SelectObject(hDC, hFont);
 	::SetBkMode(hDC, TRANSPARENT);
 	::SetTextColor(hDC, m_crText[state]);
 
@@ -237,6 +236,7 @@
 		}
 		DrawTextA(hDC, szText, (int)strlen(szText), &rcText, DT_VCENTER | DT_CENTER | DT_SINGLELINE | DT_END_ELLIPSIS);
 	}
+	::SelectObject(hDC, hOldFont);
 
 
 	// 是否有小圆点
@@ -283,8 +283,8 @@
 		::Polygon(hDC, pt, 3);
 		::SelectObject(hDC, hOldBrush);
 		::SelectObject(hDC, hOldPen);
-		::DeleteObject(hBrush);
-		::DeleteObject(hPen);
+		::DeleteObject(hbrDrop);     // 正确释放小三角使用的画刷
+		::DeleteObject(hPenDrop);    // 正确释放小三角的笔
 	}
 }
 

--
Gitblit v1.9.3