From cb3d913e147acce92bfacc34dab441abb9ab8735 Mon Sep 17 00:00:00 2001
From: LAPTOP-SNT8I5JK\Boounion <Chenluhua@qq.com>
Date: 星期二, 04 三月 2025 16:24:52 +0800
Subject: [PATCH] 1.属性页面板增加关闭按钮,关闭时隐藏,默认隐藏。
---
SourceCode/Bond/Servo/resource.h | 0
SourceCode/Bond/Servo/Servo.rc | 0
SourceCode/Bond/x64/Debug/Res/panel_close_24_a.ico | 0
SourceCode/Bond/x64/Debug/Res/panel_close_24_b.ico | 0
SourceCode/Bond/Servo/CPanelAttributes.h | 5 ++++-
SourceCode/Bond/Servo/ServoDlg.cpp | 8 ++++++--
SourceCode/Bond/Servo/CPanelAttributes.cpp | 29 ++++++++++++++++++++++++++---
7 files changed, 36 insertions(+), 6 deletions(-)
diff --git a/SourceCode/Bond/Servo/CPanelAttributes.cpp b/SourceCode/Bond/Servo/CPanelAttributes.cpp
index ef815ae..e36312d 100644
--- a/SourceCode/Bond/Servo/CPanelAttributes.cpp
+++ b/SourceCode/Bond/Servo/CPanelAttributes.cpp
@@ -37,6 +37,7 @@
ON_WM_DESTROY()
ON_WM_SIZE()
ON_NOTIFY(BYVERTICALLINE_MOVEX, IDC_LINE1, &CPanelAttributes::OnVLineMoveX)
+ ON_BN_CLICKED(IDC_BUTTON_CLOSE, &CPanelAttributes::OnBnClickedButtonClose)
END_MESSAGE_MAP()
@@ -62,11 +63,10 @@
for (unsigned int i = 0; i < nSize; i++) {
SERVO::CAttribute* pAttribute = attrubutes.getAttribute(i);
- CMFCPropertyGridProperty* pProp1 = new CMFCPropertyGridProperty(
+ m_gridCtrl.AddProperty(new CMFCPropertyGridProperty(
pAttribute->getName().c_str(),
pAttribute->getValue().c_str(),
- pAttribute->getDescription().c_str());
- m_gridCtrl.AddProperty(pProp1);
+ pAttribute->getDescription().c_str()));
}
}
@@ -74,6 +74,19 @@
{
CDialogEx::OnInitDialog();
+
+ // 鍏抽棴鎸夐挳
+ CString strIcon1;
+ strIcon1.Format(_T("%s\\Res\\panel_close_24_b.ico"), theApp.m_strAppDir);
+ HICON hIcon1 = (HICON)::LoadImage(AfxGetInstanceHandle(),
+ strIcon1, IMAGE_ICON, 24, 24,
+ LR_LOADFROMFILE | LR_DEFAULTCOLOR | LR_CREATEDIBSECTION | LR_DEFAULTSIZE);
+ m_btnClose.SubclassDlgItem(IDC_BUTTON_CLOSE, this);
+ m_btnClose.SetIcon(hIcon1, hIcon1, 24);
+ m_btnClose.SetFaceColor(m_crBkgnd);
+ m_btnClose.SetFrameColor(m_crBkgnd);
+ m_btnClose.SetFrameColor(BS_HOVER, RGB(218, 218, 218));
+ m_btnClose.SetFrameColor(BS_PRESS, RGB(168, 168, 168));
CVerticalLine* pLine1 = CVerticalLine::Hook(GetDlgItem(IDC_LINE1)->GetSafeHwnd());
pLine1->SetBkgndColor(RGB(225, 225, 225));
@@ -137,6 +150,10 @@
pItem = GetDlgItem(IDC_LABEL_TITLE);
pItem->GetWindowRect(&rcItem);
pItem->MoveWindow(5, y, rcClient.Width() - 8, rcItem.Height());
+
+ pItem = GetDlgItem(IDC_BUTTON_CLOSE);
+ pItem->GetWindowRect(&rcItem);
+ pItem->MoveWindow(rcClient.right - 6 - rcItem.Width(), y, rcItem.Width(), rcItem.Height());
y += rcItem.Height();
y += 3;
@@ -163,3 +180,9 @@
*result = 0;
}
+
+void CPanelAttributes::OnBnClickedButtonClose()
+{
+ ShowWindow(SW_HIDE);
+ GetParent()->SendMessage(ID_MSG_PANEL_RESIZE, m_nPanelWidth, 0);
+}
diff --git a/SourceCode/Bond/Servo/CPanelAttributes.h b/SourceCode/Bond/Servo/CPanelAttributes.h
index 3616a8e..5c00465 100644
--- a/SourceCode/Bond/Servo/CPanelAttributes.h
+++ b/SourceCode/Bond/Servo/CPanelAttributes.h
@@ -1,4 +1,6 @@
锘�#pragma once
+#include "BlButton.h"
+
// CPanelAttributes 瀵硅瘽妗�
@@ -18,7 +20,7 @@
HBRUSH m_hbrBkgnd;
int m_nPanelWidth;
CMFCPropertyGridCtrl m_gridCtrl;
-
+ CBlButton m_btnClose;
// 瀵硅瘽妗嗘暟鎹�
#ifdef AFX_DESIGN_TIME
@@ -35,4 +37,5 @@
afx_msg void OnDestroy();
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg void OnVLineMoveX(NMHDR* nmhdr, LRESULT* result);
+ afx_msg void OnBnClickedButtonClose();
};
diff --git a/SourceCode/Bond/Servo/Servo.rc b/SourceCode/Bond/Servo/Servo.rc
index b1bbb7e..cbcccf9 100644
--- a/SourceCode/Bond/Servo/Servo.rc
+++ b/SourceCode/Bond/Servo/Servo.rc
Binary files differ
diff --git a/SourceCode/Bond/Servo/ServoDlg.cpp b/SourceCode/Bond/Servo/ServoDlg.cpp
index f3d2cd5..922f768 100644
--- a/SourceCode/Bond/Servo/ServoDlg.cpp
+++ b/SourceCode/Bond/Servo/ServoDlg.cpp
@@ -173,6 +173,10 @@
ASSERT(pStep);
ASSERT(m_pPanelAttributes);
m_pPanelAttributes->loadDataFromStep(pStep);
+ if (!m_pPanelAttributes->IsWindowVisible()) {
+ m_pPanelAttributes->ShowWindow(SW_SHOW);
+ Resize();
+ }
}
}
@@ -316,7 +320,7 @@
m_pPanelMaster->ShowWindow(SW_SHOW);
m_pPanelAttributes = new CPanelAttributes();
m_pPanelAttributes->Create(IDD_PANEL_ATTRIBUTES, this);
- m_pPanelAttributes->ShowWindow(SW_SHOW);
+ // m_pPanelAttributes->ShowWindow(SW_SHOW);
@@ -782,7 +786,7 @@
x += nPanelWidth;
}
- if (m_pPanelAttributes != nullptr) {
+ if (m_pPanelAttributes != nullptr && m_pPanelAttributes->IsWindowVisible()) {
nPanelWidth = m_pPanelAttributes->getPanelWidth();
m_pPanelAttributes->MoveWindow(x, y, nPanelWidth, rcClient.Height());
x += nPanelWidth;
diff --git a/SourceCode/Bond/Servo/resource.h b/SourceCode/Bond/Servo/resource.h
index 593c8be..2d35cac 100644
--- a/SourceCode/Bond/Servo/resource.h
+++ b/SourceCode/Bond/Servo/resource.h
Binary files differ
diff --git a/SourceCode/Bond/x64/Debug/Res/panel_close_24_a.ico b/SourceCode/Bond/x64/Debug/Res/panel_close_24_a.ico
new file mode 100644
index 0000000..8950fff
--- /dev/null
+++ b/SourceCode/Bond/x64/Debug/Res/panel_close_24_a.ico
Binary files differ
diff --git a/SourceCode/Bond/x64/Debug/Res/panel_close_24_b.ico b/SourceCode/Bond/x64/Debug/Res/panel_close_24_b.ico
new file mode 100644
index 0000000..5df3daa
--- /dev/null
+++ b/SourceCode/Bond/x64/Debug/Res/panel_close_24_b.ico
Binary files differ
--
Gitblit v1.9.3