From 61b2bfa09588f08accb13e98ee4cd73015cb2352 Mon Sep 17 00:00:00 2001
From: LAPTOP-SNT8I5JK\Boounion <Chenluhua@qq.com>
Date: 星期二, 03 六月 2025 09:06:17 +0800
Subject: [PATCH] 1.增加任务详情弹出对话框,但具体填充数据;

---
 SourceCode/Bond/Servo/Servo.vcxproj         |    2 
 SourceCode/Bond/Servo/CMyStatusbar.h        |    3 
 SourceCode/Bond/Servo/Servo.vcxproj.filters |    2 
 SourceCode/Bond/Servo/resource.h            |    0 
 SourceCode/Bond/Servo/Servo.rc              |    0 
 SourceCode/Bond/Servo/CMyStatusbar.cpp      |   18 ++++
 SourceCode/Bond/Servo/CRobotTaskDlg.h       |   41 ++++++++++
 SourceCode/Bond/Servo/ServoDlg.cpp          |   32 ++++++++
 SourceCode/Bond/Servo/CRobotTaskDlg.cpp     |  124 +++++++++++++++++++++++++++++++
 SourceCode/Bond/Servo/ServoDlg.h            |    4 
 10 files changed, 224 insertions(+), 2 deletions(-)

diff --git a/SourceCode/Bond/Servo/CMyStatusbar.cpp b/SourceCode/Bond/Servo/CMyStatusbar.cpp
index 3432829..d0ab4fe 100644
--- a/SourceCode/Bond/Servo/CMyStatusbar.cpp
+++ b/SourceCode/Bond/Servo/CMyStatusbar.cpp
@@ -118,6 +118,22 @@
 	// TODO: 鍦ㄦ澶勬坊鍔犳秷鎭鐞嗙▼搴忎唬鐮�
 }
 
+BOOL CMyStatusbar::OnCommand(WPARAM wParam, LPARAM lParam)
+{
+	CWnd* pItem;
+	CRect rcItem;
+
+	switch (LOWORD(wParam)) {
+	case IDC_BUTTON_ROBOTTASK:
+		pItem = GetDlgItem(IDC_BUTTON_ROBOTTASK);
+		pItem->GetWindowRect(rcItem);
+		GetParent()->SendMessage(ID_MSG_STATUSBAR_BTN_CLICKED, rcItem.left, LOWORD(wParam));
+		break;
+	}
+
+	return CDialogEx::OnCommand(wParam, lParam);
+}
+
 void CMyStatusbar::OnSize(UINT nType, int cx, int cy)
 {
 	CDialogEx::OnSize(nType, cx, cy);
@@ -149,4 +165,4 @@
 	pItem->GetClientRect(rcItem);
 	pItem->MoveWindow(x, (rcClient.Height() - rcItem.Height()) / 2, rcItem.Width(), rcItem.Height());
 	x += rcItem.Width();
-}
+}
\ No newline at end of file
diff --git a/SourceCode/Bond/Servo/CMyStatusbar.h b/SourceCode/Bond/Servo/CMyStatusbar.h
index ed1d4e2..08c6c1f 100644
--- a/SourceCode/Bond/Servo/CMyStatusbar.h
+++ b/SourceCode/Bond/Servo/CMyStatusbar.h
@@ -3,6 +3,8 @@
 #include "ColorTransfer.h"
 
 
+#define ID_MSG_STATUSBAR_BTN_CLICKED		WM_USER + 20398
+
 // CMyStatusbar 瀵硅瘽妗�
 
 class CMyStatusbar : public CDialogEx
@@ -43,4 +45,5 @@
 	afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
 	afx_msg void OnDestroy();
 	afx_msg void OnSize(UINT nType, int cx, int cy);
+	virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam);
 };
diff --git a/SourceCode/Bond/Servo/CRobotTaskDlg.cpp b/SourceCode/Bond/Servo/CRobotTaskDlg.cpp
new file mode 100644
index 0000000..16fd9da
--- /dev/null
+++ b/SourceCode/Bond/Servo/CRobotTaskDlg.cpp
@@ -0,0 +1,124 @@
+锘�// CRobotTaskDlg.cpp: 瀹炵幇鏂囦欢
+//
+
+#include "stdafx.h"
+#include "Servo.h"
+#include "CRobotTaskDlg.h"
+#include "afxdialogex.h"
+
+
+// CRobotTaskDlg 瀵硅瘽妗�
+
+IMPLEMENT_DYNAMIC(CRobotTaskDlg, CDialogEx)
+
+CRobotTaskDlg::CRobotTaskDlg(CWnd* pParent /*=nullptr*/)
+	: CDialogEx(IDD_DIALOG_ROBOT_TASK, pParent)
+{
+	m_pRobotTask = nullptr;
+}
+
+CRobotTaskDlg::~CRobotTaskDlg()
+{
+}
+
+void CRobotTaskDlg::DoDataExchange(CDataExchange* pDX)
+{
+	CDialogEx::DoDataExchange(pDX);
+}
+
+
+BEGIN_MESSAGE_MAP(CRobotTaskDlg, CDialogEx)
+	ON_WM_CTLCOLOR()
+	ON_WM_DESTROY()
+	ON_WM_SIZE()
+	ON_WM_ACTIVATE()
+END_MESSAGE_MAP()
+
+
+// CRobotTaskDlg 娑堟伅澶勭悊绋嬪簭
+
+
+void CRobotTaskDlg::SetRobotTask(SERVO::CRobotTask* pRobotTask)
+{
+	m_pRobotTask = pRobotTask;
+
+
+	// 鍚勬帶浠舵槸鍚︽樉绀�;
+	GetDlgItem(IDC_LABEL_NO_TASK)->ShowWindow(m_pRobotTask == nullptr ? SW_SHOW : SW_HIDE);
+	GetDlgItem(IDC_LABEL_GET_PUT)->ShowWindow(m_pRobotTask != nullptr ? SW_SHOW : SW_HIDE);
+
+
+	if (m_pRobotTask != nullptr) {
+		SERVO::CEquipment* pEq1, * pEq2;
+		pEq1 = theApp.m_model.getMaster().getEquipment(m_pRobotTask->getSrcPosition());
+		pEq2 = theApp.m_model.getMaster().getEquipment(m_pRobotTask->getTarPosition());
+
+		CString strText;
+		strText.Format(_T("%s --> %s"), pEq1->getName().c_str(), pEq2->getName().c_str());
+		SetDlgItemText(IDC_LABEL_GET_PUT, strText);
+	}
+}
+
+BOOL CRobotTaskDlg::OnInitDialog()
+{
+	CDialogEx::OnInitDialog();
+
+	// TODO:  鍦ㄦ娣诲姞棰濆鐨勫垵濮嬪寲
+
+	return TRUE;  // return TRUE unless you set the focus to a control
+				  // 寮傚父: OCX 灞炴�ч〉搴旇繑鍥� FALSE
+}
+
+
+HBRUSH CRobotTaskDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
+{
+	HBRUSH hbr = CDialogEx::OnCtlColor(pDC, pWnd, nCtlColor);
+
+	// TODO:  鍦ㄦ鏇存敼 DC 鐨勪换浣曠壒鎬�
+
+	// TODO:  濡傛灉榛樿鐨勪笉鏄墍闇�鐢荤瑪锛屽垯杩斿洖鍙︿竴涓敾绗�
+	return hbr;
+}
+
+
+void CRobotTaskDlg::OnDestroy()
+{
+	CDialogEx::OnDestroy();
+
+	// TODO: 鍦ㄦ澶勬坊鍔犳秷鎭鐞嗙▼搴忎唬鐮�
+}
+
+void CRobotTaskDlg::OnSize(UINT nType, int cx, int cy)
+{
+	CDialogEx::OnSize(nType, cx, cy);
+	if (GetDlgItem(IDC_LABEL_NO_TASK) == nullptr) return;
+	Resize();
+}
+
+void CRobotTaskDlg::OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized)
+{
+	CWnd::OnActivate(nState, pWndOther, bMinimized);
+
+	if (nState == WA_INACTIVE) {
+		ShowWindow(SW_HIDE);
+	}
+}
+
+void CRobotTaskDlg::Resize()
+{
+	CRect rcClient, rcItem;
+	CWnd* pItem;
+	GetClientRect(&rcClient);
+
+	pItem = GetDlgItem(IDC_LABEL_NO_TASK);
+	pItem->GetClientRect(&rcItem);
+	pItem->MoveWindow((rcClient.Width() - rcItem.Width()) / 2,
+		(rcClient.Height() - rcItem.Height()) / 2, rcItem.Width(), rcItem.Height());
+
+	pItem = GetDlgItem(IDC_LABEL_GET_PUT);
+	pItem->GetClientRect(&rcItem);
+	pItem->MoveWindow(12,
+		12, rcItem.Width(), rcItem.Height());
+}
+
+
diff --git a/SourceCode/Bond/Servo/CRobotTaskDlg.h b/SourceCode/Bond/Servo/CRobotTaskDlg.h
new file mode 100644
index 0000000..8754432
--- /dev/null
+++ b/SourceCode/Bond/Servo/CRobotTaskDlg.h
@@ -0,0 +1,41 @@
+锘�#pragma once
+#include "CRobotTask.h"
+
+
+// CRobotTaskDlg 瀵硅瘽妗�
+
+class CRobotTaskDlg : public CDialogEx
+{
+	DECLARE_DYNAMIC(CRobotTaskDlg)
+
+public:
+	CRobotTaskDlg(CWnd* pParent = nullptr);   // 鏍囧噯鏋勯�犲嚱鏁�
+	virtual ~CRobotTaskDlg();
+
+public:
+	void SetRobotTask(SERVO::CRobotTask* pRobotTask);
+
+private:
+	void Resize();
+
+
+private:
+	SERVO::CRobotTask* m_pRobotTask;
+
+
+// 瀵硅瘽妗嗘暟鎹�
+#ifdef AFX_DESIGN_TIME
+	enum { IDD = IDD_DIALOG_ROBOT_TASK };
+#endif
+
+protected:
+	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV 鏀寔
+
+	DECLARE_MESSAGE_MAP()
+public:
+	virtual BOOL OnInitDialog();
+	afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
+	afx_msg void OnDestroy();
+	afx_msg void OnSize(UINT nType, int cx, int cy);
+	afx_msg void OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized);
+};
diff --git a/SourceCode/Bond/Servo/Servo.rc b/SourceCode/Bond/Servo/Servo.rc
index 65d8222..cdb2f4a 100644
--- a/SourceCode/Bond/Servo/Servo.rc
+++ b/SourceCode/Bond/Servo/Servo.rc
Binary files differ
diff --git a/SourceCode/Bond/Servo/Servo.vcxproj b/SourceCode/Bond/Servo/Servo.vcxproj
index 4ef99c5..bf0c520 100644
--- a/SourceCode/Bond/Servo/Servo.vcxproj
+++ b/SourceCode/Bond/Servo/Servo.vcxproj
@@ -205,6 +205,7 @@
     <ClInclude Include="CRobotCmdTestDlg.h" />
     <ClInclude Include="CPagePortStatus.h" />
     <ClInclude Include="CPortStatusReport.h" />
+    <ClInclude Include="CRobotTaskDlg.h" />
     <ClInclude Include="GridControl\CellRange.h" />
     <ClInclude Include="GridControl\GridCell.h" />
     <ClInclude Include="GridControl\GridCellBase.h" />
@@ -333,6 +334,7 @@
     <ClCompile Include="CRobotCmdTestDlg.cpp" />
     <ClCompile Include="CPagePortStatus.cpp" />
     <ClCompile Include="CPortStatusReport.cpp" />
+    <ClCompile Include="CRobotTaskDlg.cpp" />
     <ClCompile Include="GridControl\GridCell.cpp" />
     <ClCompile Include="GridControl\GridCellBase.cpp" />
     <ClCompile Include="GridControl\GridCellButton.cpp" />
diff --git a/SourceCode/Bond/Servo/Servo.vcxproj.filters b/SourceCode/Bond/Servo/Servo.vcxproj.filters
index f81b1d2..bd2b7b8 100644
--- a/SourceCode/Bond/Servo/Servo.vcxproj.filters
+++ b/SourceCode/Bond/Servo/Servo.vcxproj.filters
@@ -155,6 +155,7 @@
     <ClCompile Include="CMyStatusbar.cpp" />
     <ClCompile Include="CRobotTask.cpp" />
     <ClCompile Include="CSlot.cpp" />
+    <ClCompile Include="CRobotTaskDlg.cpp" />
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="AlarmManager.h" />
@@ -315,6 +316,7 @@
     <ClInclude Include="CMyStatusbar.h" />
     <ClInclude Include="CRobotTask.h" />
     <ClInclude Include="CSlot.h" />
+    <ClInclude Include="CRobotTaskDlg.h" />
   </ItemGroup>
   <ItemGroup>
     <ResourceCompile Include="Servo.rc" />
diff --git a/SourceCode/Bond/Servo/ServoDlg.cpp b/SourceCode/Bond/Servo/ServoDlg.cpp
index 1921443..17306f8 100644
--- a/SourceCode/Bond/Servo/ServoDlg.cpp
+++ b/SourceCode/Bond/Servo/ServoDlg.cpp
@@ -84,6 +84,7 @@
 	m_pPageRecipe = nullptr;
 	m_pTopToolbar = nullptr;
 	m_pMyStatusbar = nullptr;
+	m_pRobotTaskDlg = nullptr;
 }
 
 void CServoDlg::DoDataExchange(CDataExchange* pDX)
@@ -119,6 +120,7 @@
 	ON_MESSAGE(ID_MSG_PANEL_RESIZE, OnPanelResize)
 	ON_NOTIFY(BYHMTAB_SEL_CHANGED, IDC_TAB1, &CServoDlg::OnTabSelChanged)
 	ON_MESSAGE(ID_MSG_TOOLBAR_BTN_CLICKED, &CServoDlg::OnToolbarBtnClicked)
+	ON_MESSAGE(ID_MSG_STATUSBAR_BTN_CLICKED, &CServoDlg::OnStatusbarBtnClicked)
 END_MESSAGE_MAP()
 
 
@@ -187,6 +189,9 @@
 			}
 			else if (RX_CODE_EQ_ROBOT_TASK == code) {
 				SERVO::CRobotTask* pTask = theApp.m_model.getMaster().getActiveRobotTask();
+				if (m_pRobotTaskDlg != nullptr) {
+					m_pRobotTaskDlg->SetRobotTask(pTask);
+				}
 				if (pTask == nullptr) {
 					m_pMyStatusbar->setCurTaskBtnText("无");
 				}
@@ -562,6 +567,12 @@
 		m_pMyStatusbar = nullptr;
 	}
 
+	if (m_pRobotTaskDlg != nullptr) {
+		m_pRobotTaskDlg->DestroyWindow();
+		delete m_pRobotTaskDlg;
+		m_pRobotTaskDlg = nullptr;
+	}
+
 	if (m_pTerminalDisplayDlg != nullptr) {
 		m_pTerminalDisplayDlg->DestroyWindow();
 		delete m_pTerminalDisplayDlg;
@@ -793,6 +804,27 @@
 	return 0;
 }
 
+LRESULT CServoDlg::OnStatusbarBtnClicked(WPARAM wParam, LPARAM lParam)
+{
+	int id = (int)lParam;
+	int x = (int)wParam;
+	if (id == IDC_BUTTON_ROBOTTASK) {
+		if (m_pRobotTaskDlg == nullptr) {
+			m_pRobotTaskDlg = new CRobotTaskDlg();
+			m_pRobotTaskDlg->Create(IDD_DIALOG_ROBOT_TASK, this);
+		}
+
+		CRect rcBar;
+		int h = 258;
+		int w = 388;
+		m_pRobotTaskDlg->SetRobotTask(theApp.m_model.getMaster().getActiveRobotTask());
+		m_pMyStatusbar->GetWindowRect(rcBar);
+		m_pRobotTaskDlg->MoveWindow(x, rcBar.top - h, w, h);
+		m_pRobotTaskDlg->ShowWindow(SW_SHOW);
+	}
+	return 0;
+}
+
 CString& CServoDlg::GetRuntimeFormatText(CString& strText, const char* pszSuffix)
 {
 	ULONGLONG ullRunTime = (ULONGLONG)(theApp.m_model.getMaster().getRunTime() * 0.001);
diff --git a/SourceCode/Bond/Servo/ServoDlg.h b/SourceCode/Bond/Servo/ServoDlg.h
index a281b1c..ee43ac3 100644
--- a/SourceCode/Bond/Servo/ServoDlg.h
+++ b/SourceCode/Bond/Servo/ServoDlg.h
@@ -15,6 +15,7 @@
 #include "CPageGraph2.h"
 #include "TopToolbar.h"
 #include "CMyStatusbar.h"
+#include "CRobotTaskDlg.h"
 
 
 // CServoDlg 对话框
@@ -37,12 +38,12 @@
 private:
 	IObserver* m_pObserver;
 	CTerminalDisplayDlg* m_pTerminalDisplayDlg;
+	CRobotTaskDlg* m_pRobotTaskDlg;
 	CPageGraph1* m_pPageGraph1;
 	CPageGraph2* m_pPageGraph2;
 	CPageRecipe* m_pPageRecipe;
 	CPageAlarm*	 m_pPageAlarm;
 	CPageLog*	 m_pPageLog;
-
 
 // 对话框数据
 #ifdef AFX_DESIGN_TIME
@@ -95,4 +96,5 @@
 	afx_msg LRESULT OnPanelResize(WPARAM wParam, LPARAM lParam);
 	afx_msg void OnTabSelChanged(NMHDR* nmhdr, LRESULT* result);
 	LRESULT OnToolbarBtnClicked(WPARAM wParam, LPARAM lParam);
+	LRESULT OnStatusbarBtnClicked(WPARAM wParam, LPARAM lParam);
 };
diff --git a/SourceCode/Bond/Servo/resource.h b/SourceCode/Bond/Servo/resource.h
index b3b41cc..eedb474 100644
--- a/SourceCode/Bond/Servo/resource.h
+++ b/SourceCode/Bond/Servo/resource.h
Binary files differ

--
Gitblit v1.9.3