| SourceCode/Bond/SGMeasurement/SGMeasurement.rc | 补丁 | 查看 | 原始文档 | blame | 历史 | |
| SourceCode/Bond/SGMeasurement/SGMeasurement.vcxproj | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| SourceCode/Bond/SGMeasurement/SGMeasurement.vcxproj.filters | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| SourceCode/Bond/SGMeasurement/SGMeasurementDlg.cpp | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| SourceCode/Bond/SGMeasurement/SGMeasurementDlg.h | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| SourceCode/Bond/SGMeasurement/res/menu_open_dir.ico | 补丁 | 查看 | 原始文档 | blame | 历史 | |
| SourceCode/Bond/SGMeasurement/resource.h | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
SourceCode/Bond/SGMeasurement/SGMeasurement.rcBinary files differ
SourceCode/Bond/SGMeasurement/SGMeasurement.vcxproj
@@ -238,6 +238,7 @@ </ItemGroup> <ItemGroup> <Image Include="res\menu_close.ico" /> <Image Include="res\menu_open_dir.ico" /> <Image Include="res\menu_restore.ico" /> <Image Include="res\SGMeasurement.ico" /> </ItemGroup> SourceCode/Bond/SGMeasurement/SGMeasurement.vcxproj.filters
@@ -98,5 +98,8 @@ <Image Include="res\menu_close.ico"> <Filter>资源文件</Filter> </Image> <Image Include="res\menu_open_dir.ico"> <Filter>资源文件</Filter> </Image> </ItemGroup> </Project> SourceCode/Bond/SGMeasurement/SGMeasurementDlg.cpp
@@ -17,6 +17,7 @@ #define DeviceID 0 // 托盘图标 ID 与消息宏 #define ID_TRAY_OPEN_DIR 2000 // 打开目录 #define ID_TRAY_RESTORE 2001 // 恢复窗口 #define ID_TRAY_EXIT 2002 // 退出程序 #define WM_TRAY_ICON_NOTIFY (WM_USER + 1000) // 托盘图标回调消息 ID @@ -947,6 +948,7 @@ ON_WM_DRAWITEM() ON_WM_CLOSE() ON_MESSAGE(WM_TRAY_ICON_NOTIFY, &CSGMeasurementDlg::OnTrayIconClick) ON_COMMAND(ID_TRAY_OPEN_DIR, &CSGMeasurementDlg::OnTrayOpenDir) ON_COMMAND(ID_TRAY_RESTORE, &CSGMeasurementDlg::OnTrayRestore) ON_COMMAND(ID_TRAY_EXIT, &CSGMeasurementDlg::OnTrayExit) ON_BN_CLICKED(IDC_BUTTON_CONNECT, &CSGMeasurementDlg::OnBnClickedButtonConnect) @@ -1206,6 +1208,10 @@ // 图标 HICON hIcon = nullptr; if (id == ID_TRAY_OPEN_DIR) { hIcon = AfxGetApp()->LoadIcon(IDI_ICON_OPEN_DIR); } if (id == ID_TRAY_RESTORE) { hIcon = AfxGetApp()->LoadIcon(IDI_ICON_RESTORE); } @@ -1220,6 +1226,10 @@ // 文本 CString str; if (id == ID_TRAY_OPEN_DIR) { str = _T("打开目录"); } if (id == ID_TRAY_RESTORE) { str = _T("恢复界面"); } @@ -1263,22 +1273,23 @@ // 右键点击弹出菜单 CMenu menu; menu.CreatePopupMenu(); menu.AppendMenu(MF_OWNERDRAW, ID_TRAY_OPEN_DIR, (LPCTSTR)ID_TRAY_OPEN_DIR); menu.AppendMenu(MF_OWNERDRAW, ID_TRAY_RESTORE, (LPCTSTR)ID_TRAY_RESTORE); menu.AppendMenu(MF_OWNERDRAW, ID_TRAY_EXIT, (LPCTSTR)ID_TRAY_EXIT); // 加载图标 HICON hIconRestore = (HICON)::LoadImage(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_ICON_RESTORE), IMAGE_ICON, 16, 16, LR_SHARED); HICON hIconExit = (HICON)::LoadImage(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_ICON_EXIT), IMAGE_ICON, 16, 16, LR_SHARED); // 设置图标到菜单项 MENUITEMINFO mii = { sizeof(MENUITEMINFO) }; mii.fMask = MIIM_BITMAP; // 恢复菜单项图标 // 打开目录菜单项图标 mii.hbmpItem = HBMMENU_CALLBACK; menu.SetMenuItemInfo(ID_TRAY_OPEN_DIR, &mii); // 恢复窗口菜单项图标 mii.hbmpItem = HBMMENU_CALLBACK; menu.SetMenuItemInfo(ID_TRAY_RESTORE, &mii); // 退出菜单项图标 // 退出程序菜单项图标 mii.hbmpItem = HBMMENU_CALLBACK; menu.SetMenuItemInfo(ID_TRAY_EXIT, &mii); @@ -1292,6 +1303,18 @@ return 0; } void CSGMeasurementDlg::OnTrayOpenDir() { CString strDir = GetAppDirectory(); if (PathFileExists(strDir)) { ShellExecute(NULL, _T("open"), strDir, NULL, NULL, SW_SHOWDEFAULT); AppendLogLineRichStyled(_T("已打开程序目录"), LOG_COLOR_SUCCESS); } else { AppendLogLineRichStyled(_T("目录不存在,无法打开"), LOG_COLOR_ERROR); } } void CSGMeasurementDlg::OnTrayRestore() { ShowWindow(SW_SHOW); // 恢复窗口 SourceCode/Bond/SGMeasurement/SGMeasurementDlg.h
@@ -41,6 +41,7 @@ afx_msg void OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct); afx_msg void OnClose(); afx_msg LRESULT OnTrayIconClick(WPARAM wParam, LPARAM lParam); afx_msg void OnTrayOpenDir(); afx_msg void OnTrayRestore(); afx_msg void OnTrayExit(); afx_msg void OnBnClickedButtonConnect(); SourceCode/Bond/SGMeasurement/res/menu_open_dir.ico
SourceCode/Bond/SGMeasurement/resource.h
@@ -9,6 +9,7 @@ #define IDR_MAINFRAME 128 #define IDI_ICON_RESTORE 130 #define IDI_ICON_EXIT 131 #define IDI_ICON_OPEN_DIR 132 #define IDC_IPADDRESS 1000 #define IDC_BUTTON_CONNECT 1001 #define IDC_BUTTON_DISCONNECT 1002 @@ -37,7 +38,7 @@ // #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NEXT_RESOURCE_VALUE 132 #define _APS_NEXT_RESOURCE_VALUE 133 #define _APS_NEXT_COMMAND_VALUE 32771 #define _APS_NEXT_CONTROL_VALUE 1023 #define _APS_NEXT_SYMED_VALUE 101