From 44360bc2cdeee16be72f9cc4bfb42e0ac26b5b44 Mon Sep 17 00:00:00 2001
From: chenluhua1980 <Chenluhua@qq.com>
Date: 星期一, 19 一月 2026 14:47:19 +0800
Subject: [PATCH] 1.修改优化
---
SourceCode/Bond/Servo/CHMPropertyPage.cpp | 72 ++++++++++++++++++++++++++++++++++++
1 files changed, 72 insertions(+), 0 deletions(-)
diff --git a/SourceCode/Bond/Servo/CHMPropertyPage.cpp b/SourceCode/Bond/Servo/CHMPropertyPage.cpp
index 3591ec4..f5626b6 100644
--- a/SourceCode/Bond/Servo/CHMPropertyPage.cpp
+++ b/SourceCode/Bond/Servo/CHMPropertyPage.cpp
@@ -18,3 +18,75 @@
{
}
+
+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;
+}
+
+void CHMPropertyPage::HandleBtnClick(HWND hBtn)
+{
+ for (auto& kv : m_btns) {
+ if (kv.second != nullptr && kv.second->GetSafeHwnd() == hBtn) {
+ OnClickedBtn(kv.first.c_str());
+ break;
+ }
+ }
+}
+
+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