From cb4de5ef9411ce1912c6f7d6cd85506c6f619f3c Mon Sep 17 00:00:00 2001
From: chenluhua1980 <Chenluhua@qq.com>
Date: 星期三, 10 十二月 2025 15:08:55 +0800
Subject: [PATCH] 1.属性页增加按钮。

---
 SourceCode/Bond/Servo/CHMPropertyPage.cpp |   62 +++++++++++++++++++++++++++++++
 1 files changed, 62 insertions(+), 0 deletions(-)

diff --git a/SourceCode/Bond/Servo/CHMPropertyPage.cpp b/SourceCode/Bond/Servo/CHMPropertyPage.cpp
index 3591ec4..d692eb8 100644
--- a/SourceCode/Bond/Servo/CHMPropertyPage.cpp
+++ b/SourceCode/Bond/Servo/CHMPropertyPage.cpp
@@ -18,3 +18,65 @@
 {
 
 }
+
+void CHMPropertyPage::OnCreateBtns()
+{
+
+}
+
+CButton* CHMPropertyPage::CreateBtn(const char* name, int w, int h, const UINT id)
+{
+	std::string key = std::string(name);
+	auto it = m_btns.find(key);
+	if (it != m_btns.end()) {
+		return it->second;
+	}
+
+	CButton* pBtn = new CButton();
+	pBtn->Create(name, WS_CHILD, CRect(0, 0, w, h), GetParent(), id);
+	// 浣跨敤榛樿GUI瀛椾綋
+	HFONT hFont = (HFONT)::GetStockObject(DEFAULT_GUI_FONT);
+	if (hFont != nullptr) {
+		pBtn->SetFont(CFont::FromHandle(hFont), FALSE);
+	}
+	::SetProp(pBtn->GetSafeHwnd(), _T("BTN_ORDER"), (HANDLE)(INT_PTR)m_btnOrderSeq++);
+	m_btns[key] = pBtn;
+	return pBtn;
+}
+
+CButton* CHMPropertyPage::GetBtnByName(const char* name)
+{
+	auto it = m_btns.find(std::string(name));
+	if (it != m_btns.end()) {
+		return it->second;
+	}
+	return nullptr;
+}
+
+std::map<std::string, CButton*>& CHMPropertyPage::getBtns()
+{
+	return m_btns;
+}
+
+BEGIN_MESSAGE_MAP(CHMPropertyPage, CDialogEx)
+	ON_WM_DESTROY()
+END_MESSAGE_MAP()
+
+void CHMPropertyPage::OnDestroy()
+{
+	CDialogEx::OnDestroy();
+
+	for (auto& kv : m_btns) {
+		CButton* btn = kv.second;
+		if (btn != nullptr) {
+			if (::IsWindow(btn->GetSafeHwnd())) {
+				::RemoveProp(btn->GetSafeHwnd(), _T("BTN_ORDER"));
+			}
+			if (::IsWindow(btn->GetSafeHwnd())) {
+				btn->DestroyWindow();
+			}
+			delete btn;
+		}
+	}
+	m_btns.clear();
+}

--
Gitblit v1.9.3