From fc19ffcf4d130b2ef7788475f4b7d7846f56eecd Mon Sep 17 00:00:00 2001
From: LAPTOP-SNT8I5JK\Boounion <Chenluhua@qq.com>
Date: 星期五, 10 一月 2025 09:58:41 +0800
Subject: [PATCH] 1.Servo菜单项;

---
 SourceCode/Bond/Servo/resource.h            |    0 
 SourceCode/Bond/Servo/Servo.rc              |    0 
 SourceCode/Bond/Servo/ServoDlg.cpp          |  133 ++++++++++++++++++++++++++++++++++++++++++++
 SourceCode/Bond/BoounionPLC/PagePlcList.cpp |    1 
 SourceCode/Bond/Servo/ServoDlg.h            |   10 +++
 5 files changed, 143 insertions(+), 1 deletions(-)

diff --git a/SourceCode/Bond/BoounionPLC/PagePlcList.cpp b/SourceCode/Bond/BoounionPLC/PagePlcList.cpp
index 980fac0..ef6ab8b 100644
--- a/SourceCode/Bond/BoounionPLC/PagePlcList.cpp
+++ b/SourceCode/Bond/BoounionPLC/PagePlcList.cpp
@@ -202,6 +202,7 @@
 		if (m_treeCtrl.GetItemData(item) == (DWORD_PTR)pPlc) {
 			return item;
 		}
+		item = m_treeCtrl.GetNextSiblingItem(item);
 	}
 
 	return nullptr;
diff --git a/SourceCode/Bond/Servo/Servo.rc b/SourceCode/Bond/Servo/Servo.rc
index 57cf59a..9293bcc 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 b59a03d..e82b991 100644
--- a/SourceCode/Bond/Servo/ServoDlg.cpp
+++ b/SourceCode/Bond/Servo/ServoDlg.cpp
@@ -97,6 +97,16 @@
 	ON_MESSAGE(ID_MSG_LOGDLG_HIDE, &CServoDlg::OnLogDlgHide)
 	ON_WM_MOVING()
 	ON_WM_MOVE()
+	ON_COMMAND(ID_MENU_FILE_EXIT, &CServoDlg::OnMenuFileExit)
+	ON_UPDATE_COMMAND_UI(ID_MENU_FILE_EXIT, &CServoDlg::OnUpdateMenuFileExit)
+	ON_COMMAND(ID_MENU_FILE_SETTINGS, &CServoDlg::OnMenuFileSettings)
+	ON_UPDATE_COMMAND_UI(ID_MENU_FILE_SETTINGS, &CServoDlg::OnUpdateMenuFileSettings)
+	ON_COMMAND(ID_MENU_FILE_SECSTEST, &CServoDlg::OnMenuFileSecsTest)
+	ON_UPDATE_COMMAND_UI(ID_MENU_FILE_SECSTEST, &CServoDlg::OnUpdateMenuFileSecsTest)
+	ON_COMMAND(ID_MENU_WND_LOG, &CServoDlg::OnMenuWndLog)
+	ON_UPDATE_COMMAND_UI(ID_MENU_WND_LOG, &CServoDlg::OnUpdateMenuWndLog)
+	ON_COMMAND(ID_MENU_HELP_ABOUT, &CServoDlg::OnMenuHelpAbout)
+	ON_WM_INITMENUPOPUP()
 END_MESSAGE_MAP()
 
 
@@ -130,6 +140,13 @@
 	//  执行此操作
 	SetIcon(m_hIcon, TRUE);			// 设置大图标
 	SetIcon(m_hIcon, FALSE);		// 设置小图标
+
+
+									// 菜单
+	CMenu menu;
+	menu.LoadMenu(IDR_MENU_APP);
+	SetMenu(&menu);
+
 
 
 	// 图示
@@ -278,7 +295,122 @@
 	return static_cast<HCURSOR>(m_hIcon);
 }
 
+void CServoDlg::OnInitMenuPopup(CMenu* pPopupMenu, UINT nIndex, BOOL bSysMenu)
+{
+	ASSERT(pPopupMenu != NULL);
 
+	CCmdUI state;
+	state.m_pMenu = pPopupMenu;
+	ASSERT(state.m_pOther == NULL);
+	ASSERT(state.m_pParentMenu == NULL);
+
+	HMENU hParentMenu;
+	if (AfxGetThreadState()->m_hTrackingMenu == pPopupMenu->m_hMenu)
+		state.m_pParentMenu = pPopupMenu;
+	else if ((hParentMenu = ::GetMenu(m_hWnd)) != NULL)
+	{
+		CWnd* pParent = this;
+		if (pParent != NULL &&
+			(hParentMenu = ::GetMenu(pParent->m_hWnd)) != NULL)
+		{
+			int nIndexMax = ::GetMenuItemCount(hParentMenu);
+			for (int nIndex = 0; nIndex < nIndexMax; nIndex++)
+			{
+				if (::GetSubMenu(hParentMenu, nIndex) == pPopupMenu->m_hMenu)
+				{
+					state.m_pParentMenu = CMenu::FromHandle(hParentMenu);
+					break;
+				}
+			}
+		}
+	}
+
+	state.m_nIndexMax = pPopupMenu->GetMenuItemCount();
+	for (state.m_nIndex = 0; state.m_nIndex < state.m_nIndexMax;
+	state.m_nIndex++)
+	{
+		state.m_nID = pPopupMenu->GetMenuItemID(state.m_nIndex);
+		if (state.m_nID == 0)
+			continue;
+
+		ASSERT(state.m_pOther == NULL);
+		ASSERT(state.m_pMenu != NULL);
+		if (state.m_nID == (UINT)-1)
+		{
+			state.m_pSubMenu = pPopupMenu->GetSubMenu(state.m_nIndex);
+			if (state.m_pSubMenu == NULL ||
+				(state.m_nID = state.m_pSubMenu->GetMenuItemID(0)) == 0 ||
+				state.m_nID == (UINT)-1)
+			{
+				continue;
+			}
+			state.DoUpdate(this, TRUE);
+		}
+		else
+		{
+			state.m_pSubMenu = NULL;
+			state.DoUpdate(this, FALSE);
+		}
+
+		UINT nCount = pPopupMenu->GetMenuItemCount();
+		if (nCount < state.m_nIndexMax)
+		{
+			state.m_nIndex -= (state.m_nIndexMax - nCount);
+			while (state.m_nIndex < nCount &&
+				pPopupMenu->GetMenuItemID(state.m_nIndex) == state.m_nID)
+			{
+				state.m_nIndex++;
+			}
+		}
+		state.m_nIndexMax = nCount;
+	}
+}
+
+void CServoDlg::OnMenuFileSettings()
+{
+
+}
+
+void CServoDlg::OnUpdateMenuFileSettings(CCmdUI* pCmdUI)
+{
+	pCmdUI->Enable(TRUE);
+}
+
+void CServoDlg::OnMenuFileSecsTest()
+{
+	AfxMessageBox("OnMenuFileSecsTest");
+}
+
+void CServoDlg::OnUpdateMenuFileSecsTest(CCmdUI* pCmdUI)
+{
+	pCmdUI->Enable(TRUE);
+}
+
+void CServoDlg::OnMenuWndLog()
+{
+	OnBnClickedButtonLog();
+}
+
+void CServoDlg::OnUpdateMenuWndLog(CCmdUI* pCmdUI)
+{
+	pCmdUI->SetCheck(m_bShowLogWnd);
+}
+
+void CServoDlg::OnMenuFileExit()
+{
+	PostMessage(WM_CLOSE);
+}
+
+void CServoDlg::OnUpdateMenuFileExit(CCmdUI* pCmdUI)
+{
+	pCmdUI->Enable(TRUE);
+}
+
+void CServoDlg::OnMenuHelpAbout()
+{
+	CAboutDlg dlgAbout;
+	dlgAbout.DoModal();
+}
 
 void CServoDlg::OnBnClickedOk()
 {
@@ -337,7 +469,6 @@
 	}
 	ASSERT(m_pLogDlg);
 	m_pLogDlg->ShowWindow(m_bShowLogWnd ? SW_SHOW : SW_HIDE);
-	LOGE("OnBnClickedButtonLog");
 
 	UpdateLogBtn();
 }
diff --git a/SourceCode/Bond/Servo/ServoDlg.h b/SourceCode/Bond/Servo/ServoDlg.h
index df41e4a..3b1cd3b 100644
--- a/SourceCode/Bond/Servo/ServoDlg.h
+++ b/SourceCode/Bond/Servo/ServoDlg.h
@@ -60,4 +60,14 @@
 	afx_msg LRESULT OnLogDlgHide(WPARAM wParam, LPARAM lParam);
 	afx_msg void OnMoving(UINT fwSide, LPRECT pRect);
 	afx_msg void OnMove(int x, int y);
+	afx_msg void OnInitMenuPopup(CMenu* pPopupMenu, UINT nIndex, BOOL bSysMenu);
+	afx_msg void OnMenuFileSettings();
+	afx_msg void OnUpdateMenuFileSettings(CCmdUI* pCmdUI);
+	afx_msg void OnMenuFileSecsTest();
+	afx_msg void OnUpdateMenuFileSecsTest(CCmdUI* pCmdUI);
+	afx_msg void OnMenuWndLog();
+	afx_msg void OnUpdateMenuWndLog(CCmdUI* pCmdUI);
+	afx_msg void OnMenuFileExit();
+	afx_msg void OnUpdateMenuFileExit(CCmdUI* pCmdUI);
+	afx_msg void OnMenuHelpAbout();
 };
diff --git a/SourceCode/Bond/Servo/resource.h b/SourceCode/Bond/Servo/resource.h
index 0431ed5..b6be59f 100644
--- a/SourceCode/Bond/Servo/resource.h
+++ b/SourceCode/Bond/Servo/resource.h
Binary files differ

--
Gitblit v1.9.3