From df0863b2c29fa227d186e6b8aeb4a856dcae12f3 Mon Sep 17 00:00:00 2001
From: LAPTOP-SNT8I5JK\Boounion <Chenluhua@qq.com>
Date: 星期一, 02 十二月 2024 13:57:42 +0800
Subject: [PATCH] 1.增加PLC组件页
---
SourceCode/Bond/BondEq/Resource.h | 0
SourceCode/Bond/BondEq/BondEqDlg.h | 5
SourceCode/Bond/BondEq/CComponentPLCDlg.h | 37 ++
SourceCode/Bond/BondEq/BondEq.rc | 0
SourceCode/Bond/BondEq/CComponentPLCDlg.cpp | 123 +++++++++
SourceCode/Bond/BondEq/BondEqDlg.cpp | 65 ++++
SourceCode/Bond/BondEq/CComponentDlg.h | 73 +++++
SourceCode/Bond/BondEq/BondEq.vcxproj | 4
SourceCode/Bond/BondEq/CComponentDlg.cpp | 415 +++++++++++++++++++++++++++++++
SourceCode/Bond/BondEq/Common.h | 2
10 files changed, 719 insertions(+), 5 deletions(-)
diff --git a/SourceCode/Bond/BondEq/BondEq.rc b/SourceCode/Bond/BondEq/BondEq.rc
index addf288..02dcd4b 100644
--- a/SourceCode/Bond/BondEq/BondEq.rc
+++ b/SourceCode/Bond/BondEq/BondEq.rc
Binary files differ
diff --git a/SourceCode/Bond/BondEq/BondEq.vcxproj b/SourceCode/Bond/BondEq/BondEq.vcxproj
index 4594fa2..a8fc121 100644
--- a/SourceCode/Bond/BondEq/BondEq.vcxproj
+++ b/SourceCode/Bond/BondEq/BondEq.vcxproj
@@ -191,6 +191,8 @@
<Text Include="ReadMe.txt" />
</ItemGroup>
<ItemGroup>
+ <ClInclude Include="CComponentDlg.h" />
+ <ClInclude Include="CComponentPLCDlg.h" />
<ClInclude Include="CPLC.h" />
<ClInclude Include="AccordionWnd.h" />
<ClInclude Include="Alarm.h" />
@@ -261,6 +263,8 @@
<ClInclude Include="View\UserManagerDlg.h" />
</ItemGroup>
<ItemGroup>
+ <ClCompile Include="CComponentDlg.cpp" />
+ <ClCompile Include="CComponentPLCDlg.cpp" />
<ClCompile Include="CPLC.cpp" />
<ClCompile Include="AccordionWnd.cpp" />
<ClCompile Include="Alarm.cpp" />
diff --git a/SourceCode/Bond/BondEq/BondEqDlg.cpp b/SourceCode/Bond/BondEq/BondEqDlg.cpp
index 63256a0..70bde1c 100644
--- a/SourceCode/Bond/BondEq/BondEqDlg.cpp
+++ b/SourceCode/Bond/BondEq/BondEqDlg.cpp
@@ -74,6 +74,7 @@
m_pMainContainer = nullptr;
m_pHomeDialog = nullptr;
m_pActiveView = nullptr;
+ m_pActiveComponentDlg = nullptr;
}
void CBondEqDlg::DoDataExchange(CDataExchange* pDX)
@@ -134,7 +135,26 @@
}
}
}
+ else if (RX_CODE_SELECT_COMPONENT == code) {
+ CComponent* pComponent;
+ if (pAny->getPtrValue("ptr", (void*&)pComponent)) {
+ if (pComponent->getClassName().compare("CPLC") == 0) {
+ if (m_pMainContainer != nullptr) {
+ if (m_pActiveComponentDlg != nullptr) {
+ if (m_pActiveComponentDlg->GetContext() != (void*)pComponent) {
+ m_pActiveComponentDlg->DestroyWindow();
+ delete m_pActiveComponentDlg;
+ m_pActiveComponentDlg = nullptr;
+ }
+ }
+ if (m_pActiveComponentDlg == nullptr) {
+ m_pActiveComponentDlg = CreateComponentPLCDlg(pComponent);
+ }
+ }
+ }
+ }
+ }
pAny->release();
}, [&]() -> void {
// onComplete
@@ -366,6 +386,12 @@
m_pActiveView = nullptr;
}
+ if (m_pActiveComponentDlg != nullptr) {
+ m_pActiveComponentDlg->DestroyWindow();
+ delete m_pActiveComponentDlg;
+ m_pActiveComponentDlg = nullptr;
+ }
+
if (m_hbrBkgnd != nullptr) {
::DeleteObject(m_hbrBkgnd);
}
@@ -482,19 +508,18 @@
void CBondEqDlg::OnMenuFileSettings()
{
- /*
CAxisSettingsDlg axisDlg;
axisDlg.SetPLC(theApp.m_model.getBonder().getPLC("PLC(1)"));
axisDlg.SetRecipeName(_T("Default"));
axisDlg.DoModal();
- */
// Cavity VacuumBake AfterBake AOI
+ /*
CIOMonitoringDlg dlg;
dlg.SetIOManager("Cavity");
dlg.SetPLC(theApp.m_model.getBonder().getPLC("PLC(1)"));
dlg.DoModal();
-
+ */
/*
CSettingsDlg dlg;
@@ -548,7 +573,7 @@
{
int id = (int)lParam;
if (id == VIEW_TOOL_BTN_CLOSE) {
- CloseView((CBaseView*)wParam);
+ CloseView((CComponentDlg*)wParam);
}
return 0;
@@ -658,6 +683,14 @@
m_pMainContainer->Resize();
}
+void CBondEqDlg::CloseView(CComponentDlg* pView)
+{
+ pView->DestroyWindow();
+ delete pView;
+ m_pActiveComponentDlg = nullptr;
+ m_pMainContainer->Resize();
+}
+
CHomeDialog* CBondEqDlg::CreateHomeDlg()
{
CHomeDialog* pDlg = new CHomeDialog(m_pMainContainer);
@@ -741,3 +774,27 @@
m_pTopToolbar->SetOperatorBtnText(_T("未登录"));
}
}
+
+CComponentPLCDlg* CBondEqDlg::CreateComponentPLCDlg(CComponent* pComponent)
+{
+ CComponentPLCDlg* pDlg = new CComponentPLCDlg(m_pMainContainer);
+ pDlg->Create(IDD_COMPONENT_PLC, m_pMainContainer);
+ pDlg->SetContext(pComponent);
+
+ CString strIcon0, strIcon1, strIcon2, strIcon3;
+ strIcon0.Format(_T("%s\\Res\\small_close0.ico"), (LPTSTR)(LPCTSTR)theApp.m_strAppDir);
+ strIcon1.Format(_T("%s\\Res\\small_close1.ico"), (LPTSTR)(LPCTSTR)theApp.m_strAppDir);
+ strIcon2.Format(_T("%s\\Res\\small_close2.ico"), (LPTSTR)(LPCTSTR)theApp.m_strAppDir);
+ strIcon3.Format(_T("%s\\Res\\small_close3.ico"), (LPTSTR)(LPCTSTR)theApp.m_strAppDir);
+ pDlg->AddToolBtn(VIEW_TOOL_BTN_CLOSE,
+ (LPTSTR)(LPCTSTR)strIcon0,
+ (LPTSTR)(LPCTSTR)strIcon1,
+ (LPTSTR)(LPCTSTR)strIcon2,
+ (LPTSTR)(LPCTSTR)strIcon3, "关闭");
+ pDlg->ShowWindow(SW_SHOW);
+ pDlg->SetWindowText(pComponent->getName().c_str());
+ m_pMainContainer->Resize();
+
+ return pDlg;
+}
+
diff --git a/SourceCode/Bond/BondEq/BondEqDlg.h b/SourceCode/Bond/BondEq/BondEqDlg.h
index bcb13fd..d7827a3 100644
--- a/SourceCode/Bond/BondEq/BondEqDlg.h
+++ b/SourceCode/Bond/BondEq/BondEqDlg.h
@@ -9,6 +9,7 @@
#include "CBaseView.h"
#include "CRemoteEqView.h"
#include "TopToolbar.h"
+#include "CComponentPLCDlg.h"
// CBondEqDlg 对话框
@@ -22,8 +23,10 @@
void InitRxWindows();
void Resize();
void CloseView(CBaseView* pView);
+ void CloseView(CComponentDlg* pView);
CHomeDialog* CreateHomeDlg();
CBaseView* CreateRemoteEqView(BEQ::IRemoteEquipment* pEquipment);
+ CComponentPLCDlg* CreateComponentPLCDlg(CComponent* pComponent);
void UpdateLoginStatus();
private:
@@ -35,7 +38,7 @@
CPanelProject* m_pPanelProject;
CHomeDialog* m_pHomeDialog;
CBaseView* m_pActiveView;
-
+ CComponentDlg* m_pActiveComponentDlg;
// 对话框数据
#ifdef AFX_DESIGN_TIME
diff --git a/SourceCode/Bond/BondEq/CComponentDlg.cpp b/SourceCode/Bond/BondEq/CComponentDlg.cpp
new file mode 100644
index 0000000..47bffd7
--- /dev/null
+++ b/SourceCode/Bond/BondEq/CComponentDlg.cpp
@@ -0,0 +1,415 @@
+#include "stdafx.h"
+#include "CComponentDlg.h"
+#include "Common.h"
+
+
+#define CAPTION_HEIGHT 36
+#define CAPBTN 99
+
+
+IMPLEMENT_DYNAMIC(CComponentDlg, CDialogEx)
+
+CComponentDlg::CComponentDlg(UINT id, CWnd* pPage) : CDialogEx(id, pPage)
+{
+ m_crBkgnd = COMPONENT_DLG_BACKGROUND;
+ m_hbrBkgnd = nullptr;
+ m_pContext = nullptr;
+ m_nState = 0;
+ m_pHotBtn = nullptr;
+ m_pPressBtn = nullptr;
+}
+
+CComponentDlg::~CComponentDlg()
+{
+}
+
+BEGIN_MESSAGE_MAP(CComponentDlg, CDialogEx)
+ ON_WM_CTLCOLOR()
+ ON_WM_DESTROY()
+ ON_WM_ACTIVATE()
+ ON_WM_NCPAINT()
+ ON_WM_MOUSEACTIVATE()
+ ON_WM_SIZE()
+ ON_WM_NCCALCSIZE()
+ ON_WM_LBUTTONDOWN()
+ ON_WM_NCHITTEST()
+ ON_WM_NCMOUSEMOVE()
+ ON_WM_NCLBUTTONDOWN()
+ ON_WM_NCLBUTTONUP()
+END_MESSAGE_MAP()
+
+HBRUSH CComponentDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
+{
+ HBRUSH hbr = CDialogEx::OnCtlColor(pDC, pWnd, nCtlColor);
+
+ if (nCtlColor == CTLCOLOR_STATIC) {
+ pDC->SetBkColor(m_crBkgnd);
+ }
+
+ if (m_hbrBkgnd == nullptr) {
+ m_hbrBkgnd = CreateSolidBrush(m_crBkgnd);
+ }
+
+ return m_hbrBkgnd;
+}
+
+
+void CComponentDlg::OnDestroy()
+{
+ CDialogEx::OnDestroy();
+}
+
+void CComponentDlg::OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized)
+{
+ CDialogEx::OnActivate(nState, pWndOther, bMinimized);
+
+ if (WA_INACTIVE == nState) {
+ OnApply();
+ }
+}
+
+void CComponentDlg::OnNcPaint()
+{
+ // TODO: 在此处添加消息处理程序代码
+ // 不为绘图消息调用 CDialogEx::OnNcPaint()
+
+
+ RECT rect, rcClient;
+ ::GetClientRect(m_hWnd, &rcClient);
+ ::ClientToScreen(m_hWnd, (LPPOINT)&rcClient.left);
+ ::ClientToScreen(m_hWnd, (LPPOINT)&rcClient.right);
+ ::GetWindowRect(m_hWnd, &rect);
+ ::OffsetRect(&rcClient, -rect.left, -rect.top);
+
+ rect.right -= rect.left;
+ rect.bottom -= rect.top;
+ rect.left = 0;
+ rect.top = 0;
+
+ HRGN hRgnWnd = CreateRectRgnIndirect(&rect);
+ HRGN hRgnClient = CreateRectRgnIndirect(&rcClient);
+
+ HBRUSH hBrushBK, hBrushFrame;
+ HDC hDC = ::GetWindowDC(m_hWnd);
+ ::SelectClipRgn(hDC, hRgnWnd);
+ ::ExtSelectClipRgn(hDC, hRgnClient, RGN_DIFF);
+
+
+ // 背景
+ hBrushBK = CreateSolidBrush(m_crBkgnd);
+ ::FillRect(hDC, &rect, hBrushBK);
+ DeleteObject(hBrushBK);
+
+
+ // 标题栏,文字,横线
+ HFONT hFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
+ ::SelectObject(hDC, hFont);
+
+ RECT rcCaption, rcText;
+ rcCaption = rect;
+ rcCaption.bottom = rcCaption.top + CAPTION_HEIGHT;
+ rcText = rcCaption;
+ rcText.left += 12;
+ char szCaption[64];
+ int nCaptionLen = GetWindowText(szCaption, 64);
+ ::DrawText(hDC, szCaption, nCaptionLen, &rcText, DT_LEFT | DT_VCENTER | DT_SINGLELINE | DT_END_ELLIPSIS);
+
+
+ HPEN hPen = CreatePen(PS_SOLID, 1, RGB(222, 222, 222));
+ HPEN hOldPen = (HPEN)::SelectObject(hDC, hPen);
+ ::MoveToEx(hDC, 0, rcCaption.bottom, NULL);
+ ::LineTo(hDC, rect.right, rcCaption.bottom);
+ ::SelectObject(hDC, hOldPen);
+ ::DeleteObject(hPen);
+
+
+ // 绘制按钮
+ int y = (rcCaption.bottom - rcCaption.top - 24) / 2;
+ int x = rcCaption.right - 12;
+ for (auto& item : m_toolbtns) {
+ if (item.hIcon != nullptr) {
+ if (!item.bEnable) {
+ DrawIconEx(hDC, x - 24, y,
+ item.hIcon[3], 24, 24, 0, 0, DI_NORMAL);
+ }
+ else if (m_pPressBtn == &item) {
+ DrawIconEx(hDC, x - 24, y,
+ item.hIcon[2], 24, 24, 0, 0, DI_NORMAL);
+ }
+ else if (m_pHotBtn == &item) {
+ DrawIconEx(hDC, x - 24, y,
+ item.hIcon[1], 24, 24, 0, 0, DI_NORMAL);
+ }
+ else {
+ DrawIconEx(hDC, x - 24, y,
+ item.hIcon[0], 24, 24, 0, 0, DI_NORMAL);
+ }
+ x -= 24;
+ x -= 3;
+ }
+ }
+
+
+
+ hBrushFrame = CreateSolidBrush(RGB(255, 0, 0));
+ // ::FrameRect(hDC, &rect, hBrushFrame);
+
+ ::DeleteObject(hRgnWnd);
+ ::DeleteObject(hRgnClient);
+ DeleteObject(hBrushFrame);
+ ::ReleaseDC(m_hWnd, hDC);
+}
+
+int CComponentDlg::OnMouseActivate(CWnd* pDesktopWnd, UINT nHitTest, UINT message)
+{
+ // TODO: 在此添加消息处理程序代码和/或调用默认值
+ int nRet = CDialogEx::OnMouseActivate(pDesktopWnd, nHitTest, message);
+ GetParent()->GetParent()->SendMessage(ID_MSG_VIEW_ACTIVE, (WPARAM)this, nRet);
+ return nRet;
+}
+
+void CComponentDlg::OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS* lpncsp)
+{
+ lpncsp->rgrc[0].top += (CAPTION_HEIGHT);
+ CDialogEx::OnNcCalcSize(bCalcValidRects, lpncsp);
+}
+
+void CComponentDlg::SetContext(void* pContext)
+{
+ m_pContext = pContext;
+}
+
+void* CComponentDlg::GetContext()
+{
+ return m_pContext;
+}
+
+void CComponentDlg::OnApply()
+{
+
+}
+
+void CComponentDlg::Show(CWnd* pParent, LPRECT lprcBtn)
+{
+ RECT rcClient, rcBox;
+ pParent->GetClientRect(&rcClient);
+ pParent->ClientToScreen(&rcClient);
+ GetWindowRect(&rcBox);
+
+ int x = lprcBtn->left;
+ if (x + (rcBox.right - rcBox.left) > rcClient.right) {
+ x = rcClient.right - (rcBox.right - rcBox.left);
+ }
+ SetWindowPos(NULL, x, lprcBtn->bottom + 2, 0, 0, SWP_NOSIZE);
+ ShowWindow(SW_SHOW);
+}
+
+void CComponentDlg::OnViewActive()
+{
+ m_nState = 1;
+ SendMessage(WM_NCPAINT, 0, 0);
+}
+
+void CComponentDlg::OnViewInactive()
+{
+ m_nState = 0;
+ SendMessage(WM_NCPAINT, 0, 0);
+}
+
+void CComponentDlg::AddToolBtn(int id, const char* pszIcon0Path, const char* pszIcon1Path, const char* pszIcon2Path, const char* pszIcon3Path, const char* pszTooltip)
+{
+ TOOLBTN tb;
+ memset(&tb, 0, sizeof(TOOLBTN));
+ tb.id = id;
+ tb.hIcon[0] = (HICON)::LoadImage(GetModuleHandle(NULL), pszIcon0Path, IMAGE_ICON, 24, 24,
+ LR_LOADFROMFILE | LR_DEFAULTCOLOR | LR_CREATEDIBSECTION | LR_DEFAULTSIZE);
+ tb.hIcon[1] = (HICON)::LoadImage(GetModuleHandle(NULL), pszIcon1Path, IMAGE_ICON, 24, 24,
+ LR_LOADFROMFILE | LR_DEFAULTCOLOR | LR_CREATEDIBSECTION | LR_DEFAULTSIZE);
+ tb.hIcon[2] = (HICON)::LoadImage(GetModuleHandle(NULL), pszIcon2Path, IMAGE_ICON, 24, 24,
+ LR_LOADFROMFILE | LR_DEFAULTCOLOR | LR_CREATEDIBSECTION | LR_DEFAULTSIZE);
+ tb.hIcon[3] = (HICON)::LoadImage(GetModuleHandle(NULL), pszIcon3Path, IMAGE_ICON, 24, 24,
+ LR_LOADFROMFILE | LR_DEFAULTCOLOR | LR_CREATEDIBSECTION | LR_DEFAULTSIZE);
+ strcpy_s(tb.szTooltip, 256, pszTooltip);
+ tb.bEnable = TRUE;
+ m_toolbtns.push_back(tb);
+
+ EnableToolTips(TRUE);
+}
+
+void CComponentDlg::SetToolBtnEnable(int id, BOOL bEnable)
+{
+ CComponentDlg::TOOLBTN* pBtn = GetToolBtn(id);
+ if (pBtn != nullptr) {
+ pBtn->bEnable = bEnable;
+ SendMessage(WM_NCPAINT);
+ }
+}
+
+void CComponentDlg::SetToolBtnMenu(int id, HMENU hMenu)
+{
+ CComponentDlg::TOOLBTN* pBtn = GetToolBtn(id);
+ if (pBtn != nullptr) {
+ pBtn->hMenu = hMenu;
+ }
+}
+
+void CComponentDlg::OnLButtonDown(UINT nFlags, CPoint point)
+{
+ // TODO: 在此添加消息处理程序代码和/或调用默认值
+
+ CDialogEx::OnLButtonDown(nFlags, point);
+}
+
+
+LRESULT CComponentDlg::OnNcHitTest(CPoint point)
+{
+ TOOLBTN* pBtn;
+ LRESULT hit = MyHitTest(point, pBtn);
+ if (hit == HTCAPTION || hit == CAPBTN) {
+ return hit;
+ }
+
+ return CDialogEx::OnNcHitTest(point);
+}
+
+void CComponentDlg::OnNcMouseMove(UINT nHitTest, CPoint point)
+{
+ TOOLBTN* pLastHot = m_pHotBtn;
+ int code = MyHitTest(point, m_pHotBtn);
+ if (pLastHot != m_pHotBtn) {
+ SendMessage(WM_NCPAINT, 0, 0);
+ }
+
+
+ CDialogEx::OnNcMouseMove(nHitTest, point);
+}
+
+void CComponentDlg::OnNcLButtonDown(UINT nHitTest, CPoint point)
+{
+ int code = MyHitTest(point, m_pPressBtn);
+ SendMessage(WM_NCPAINT, 0, 0);
+ GetParent()->GetParent()->SendMessage(ID_MSG_VIEW_ACTIVE, (WPARAM)this, MA_ACTIVATE);
+
+ CDialogEx::OnNcLButtonDown(nHitTest, point);
+}
+
+void CComponentDlg::OnNcLButtonUp(UINT nHitTest, CPoint point)
+{
+ MyHitTest(point, m_pHotBtn);
+ if (m_pPressBtn == m_pHotBtn && m_pPressBtn != nullptr && m_pPressBtn->bEnable) {
+ if (m_pPressBtn->hMenu != nullptr) {
+ int cmd = ::TrackPopupMenu(::GetSubMenu(m_pPressBtn->hMenu, 0),
+ TPM_LEFTALIGN | TPM_RIGHTBUTTON | TPM_RETURNCMD,
+ point.x, point.y + 2, 0, m_hWnd, NULL);
+ GetParent()->GetParent()->PostMessage(ID_MSG_BTN_MENU_ITEM, (WPARAM)this, cmd);
+ }
+ else {
+ GetParent()->GetParent()->PostMessage(ID_MSG_BTN_CLICKED, (WPARAM)this, m_pPressBtn->id);
+ }
+ }
+ m_pPressBtn = nullptr;
+
+ SendMessage(WM_NCPAINT, 0, 0);
+
+
+ CDialogEx::OnNcLButtonUp(nHitTest, point);
+}
+
+int CComponentDlg::MyHitTest(POINT& point, TOOLBTN*& pBtn)
+{
+ RECT rcWnd, rcCaption;
+ GetWindowRect(&rcWnd);
+ LRESULT hit = HTNOWHERE;
+ pBtn = nullptr;
+
+ rcCaption.left = rcWnd.left + 2;
+ rcCaption.right = rcWnd.right - 2;
+ rcCaption.top = rcWnd.top += 2;
+ rcCaption.bottom = rcCaption.top + 2 + CAPTION_HEIGHT;
+ if (::PtInRect(&rcCaption, point)) {
+ hit = HTCAPTION;
+
+ RECT rcIcon;
+ rcIcon.top = rcCaption.top + (rcCaption.bottom - rcCaption.top - 24) / 2;
+ rcIcon.bottom = rcIcon.top + 24;
+ rcIcon.right = rcCaption.right - 12;
+ for (auto& item : m_toolbtns) {
+ rcIcon.left = rcIcon.right - 24;
+ if (::PtInRect(&rcIcon, point)) {
+ pBtn = &item;
+ hit = CAPBTN;
+ break;
+ }
+ rcIcon.right = rcIcon.left - 3;
+ }
+ }
+
+ return (int)hit;
+}
+
+CComponentDlg::TOOLBTN* CComponentDlg::GetToolBtn(int id)
+{
+ for (auto& item : m_toolbtns) {
+ if (item.id == id) return &item;
+ }
+
+ return nullptr;
+}
+
+BOOL CComponentDlg::GetBtnRect(int id, LPRECT lprcBtn)
+{
+ RECT rcWnd, rcCaption;
+ GetWindowRect(&rcWnd);
+ ::OffsetRect(&rcWnd, -rcWnd.left, -rcWnd.top);
+ rcCaption.left = rcWnd.left + 2;
+ rcCaption.right = rcWnd.right - 2;
+ rcCaption.top = rcWnd.top += 2;
+ rcCaption.bottom = rcCaption.top + 2 + CAPTION_HEIGHT;
+
+ lprcBtn->top = rcCaption.top + (rcCaption.bottom - rcCaption.top - 24) / 2;
+ lprcBtn->bottom = lprcBtn->top + 24;
+ lprcBtn->right = rcCaption.right - 12;
+ for (auto& item : m_toolbtns) {
+ lprcBtn->left = lprcBtn->right - 24;
+ if (item.id == id) {
+ return TRUE;
+ }
+ lprcBtn->right = lprcBtn->left - 3;
+ }
+
+ return FALSE;
+}
+
+INT_PTR CComponentDlg::OnToolHitTest(CPoint point, TOOLINFO* pTI) const
+{
+ RECT rcClient, rcCaption, rcBtn;
+ ::GetClientRect(m_hWnd, &rcClient);
+ rcCaption.bottom = 0;
+ rcCaption.top = rcCaption.bottom - CAPTION_HEIGHT;
+ rcCaption.left = rcClient.left;
+ rcCaption.right = rcClient.right;
+ rcBtn.top = rcCaption.top + (rcCaption.bottom - rcCaption.top - 24) / 2;
+ rcBtn.bottom = rcBtn.top + 24;
+ rcBtn.right = rcCaption.right - 12;
+ ::OffsetRect(&rcBtn, +5, -5); // 5为边框粗的修正
+
+ if ((point.y <= 0)) {
+ for (auto& item : m_toolbtns) {
+ rcBtn.left = rcBtn.right - 24;
+ if (::PtInRect(&rcBtn, point)) {
+ pTI->rect = rcBtn;
+ pTI->hwnd = m_hWnd;
+ pTI->uId = (UINT)1020; // Tooltip should show `1020
+ pTI->lpszText = _tcsdup(item.szTooltip);
+ return pTI->uId;
+ }
+
+ rcBtn.right = rcBtn.left - 3;
+ }
+ }
+
+
+ return CDialogEx::OnToolHitTest(point, pTI);
+}
+
+
diff --git a/SourceCode/Bond/BondEq/CComponentDlg.h b/SourceCode/Bond/BondEq/CComponentDlg.h
new file mode 100644
index 0000000..865f2b3
--- /dev/null
+++ b/SourceCode/Bond/BondEq/CComponentDlg.h
@@ -0,0 +1,73 @@
+#pragma once
+
+#define ID_MSG_VIEW_ACTIVE WM_USER+2356
+#define ID_MSG_BTN_CLICKED WM_USER+2357
+#define ID_MSG_BTN_MENU_ITEM WM_USER+2358
+
+
+class CComponentDlg : public CDialogEx
+{
+private:
+ typedef struct _TOOLBTN
+ {
+ int id;
+ HICON hIcon[4];
+ char szTooltip[256];
+ BOOL bEnable;
+ HMENU hMenu;
+ } TOOLBTN;
+
+
+ DECLARE_DYNAMIC(CComponentDlg)
+
+public:
+ CComponentDlg(UINT id, CWnd* pPage); // 标准构造函数
+ virtual ~CComponentDlg();
+
+
+public:
+ void OnViewActive();
+ void OnViewInactive();
+ void AddToolBtn(int id, const char* pszIcon0Path, const char* pszIcon1Path, const char* pszIcon2Path, const char* pszIcon3Path, const char* pszTooltip);
+ void SetToolBtnEnable(int id, BOOL bEnable);
+ void SetToolBtnMenu(int id, HMENU hMenu);
+ void Show(CWnd* pParent, LPRECT lprcBtn);
+ void SetContext(void* pContext);
+ void* GetContext();
+ virtual void OnApply();
+
+private:
+ int MyHitTest(POINT& point, TOOLBTN*& pBtn);
+ CComponentDlg::TOOLBTN* GetToolBtn(int id);
+ BOOL GetBtnRect(int id, LPRECT lprcBtn);
+
+
+private:
+ std::vector<TOOLBTN> m_toolbtns;
+ TOOLBTN* m_pHotBtn;
+ TOOLBTN* m_pPressBtn;
+ int m_nState;
+
+
+protected:
+ COLORREF m_crBkgnd;
+ HBRUSH m_hbrBkgnd;
+ void* m_pContext;
+
+
+ DECLARE_MESSAGE_MAP()
+public:
+ afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
+ afx_msg void OnDestroy();
+ afx_msg void OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized);
+ afx_msg void OnNcPaint();
+ afx_msg int OnMouseActivate(CWnd* pDesktopWnd, UINT nHitTest, UINT message);
+ afx_msg void OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS* lpncsp);
+ afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
+ afx_msg LRESULT OnNcHitTest(CPoint point);
+ afx_msg void OnNcMouseMove(UINT nHitTest, CPoint point);
+ afx_msg void OnNcLButtonDown(UINT nHitTest, CPoint point);
+ afx_msg void OnNcLButtonUp(UINT nHitTest, CPoint point);
+ virtual INT_PTR OnToolHitTest(CPoint point, TOOLINFO* pTI) const;
+};
+
diff --git a/SourceCode/Bond/BondEq/CComponentPLCDlg.cpp b/SourceCode/Bond/BondEq/CComponentPLCDlg.cpp
new file mode 100644
index 0000000..6e68ab6
--- /dev/null
+++ b/SourceCode/Bond/BondEq/CComponentPLCDlg.cpp
@@ -0,0 +1,123 @@
+锘�// CComponentData1Dlg.cpp: 瀹炵幇鏂囦欢
+//
+
+#include "stdafx.h"
+#include "BondEq.h"
+#include "CComponentPLCDlg.h"
+#include "afxdialogex.h"
+#include "Log.h"
+#include "ToolUnits.h"
+#include "Common.h"
+
+
+// CComponentData1Dlg 瀵硅瘽妗�
+
+IMPLEMENT_DYNAMIC(CComponentPLCDlg, CComponentDlg)
+
+CComponentPLCDlg::CComponentPLCDlg(CWnd* pParent /*=nullptr*/)
+ : CComponentDlg(IDD_COMPONENT_PLC, pParent)
+{
+ m_pObserver = nullptr;
+}
+
+CComponentPLCDlg::~CComponentPLCDlg()
+{
+}
+
+void CComponentPLCDlg::DoDataExchange(CDataExchange* pDX)
+{
+ CComponentDlg::DoDataExchange(pDX);
+}
+
+
+BEGIN_MESSAGE_MAP(CComponentPLCDlg, CComponentDlg)
+ ON_WM_CTLCOLOR()
+ ON_WM_DESTROY()
+ ON_WM_SIZE()
+END_MESSAGE_MAP()
+
+
+// CComponentData1Dlg 娑堟伅澶勭悊绋嬪簭
+
+void CComponentPLCDlg::InitRxWindows()
+{
+ /* code */
+ // 璁㈤槄鏁版嵁
+ IRxWindows* pRxWindows = RX_GetRxWindows();
+ if (m_pObserver == NULL) {
+ m_pObserver = pRxWindows->allocObserver([&](IAny* pAny) -> void {
+ // onNext
+ pAny->addRef();
+ int code = pAny->getCode();
+ if (RX_CODE_ALARM_EVENT == code) {
+
+ }
+ pAny->release();
+ }, [&]() -> void {
+ // onComplete
+ }, [&](IThrowable* pThrowable) -> void {
+ // onErrorm
+ pThrowable->printf();
+ });
+
+ theApp.m_model.getObservable()->observeOn(pRxWindows->mainThread())
+ ->subscribe(m_pObserver);
+ }
+}
+
+BOOL CComponentPLCDlg::OnInitDialog()
+{
+ CComponentDlg::OnInitDialog();
+
+
+ return TRUE; // return TRUE unless you set the focus to a control
+ // 寮傚父: OCX 灞炴�ч〉搴旇繑鍥� FALSE
+}
+
+
+HBRUSH CComponentPLCDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
+{
+ HBRUSH hbr = CDialogEx::OnCtlColor(pDC, pWnd, nCtlColor);
+
+ if (nCtlColor == CTLCOLOR_STATIC) {
+ pDC->SetBkColor(m_crBkgnd);
+ }
+
+ if (m_hbrBkgnd == nullptr) {
+ m_hbrBkgnd = CreateSolidBrush(m_crBkgnd);
+ }
+
+ return m_hbrBkgnd;
+}
+
+
+void CComponentPLCDlg::OnDestroy()
+{
+ CComponentDlg::OnDestroy();
+
+ if (m_hbrBkgnd != nullptr) {
+ ::DeleteObject(m_hbrBkgnd);
+ }
+
+ if (m_pObserver != NULL) {
+ m_pObserver->unsubscribe();
+ m_pObserver = NULL;
+ }
+}
+
+
+void CComponentPLCDlg::OnSize(UINT nType, int cx, int cy)
+{
+ CComponentDlg::OnSize(nType, cx, cy);
+ //if (GetDlgItem(IDC_LIST_ALARM) == nullptr) return;
+/*
+ int y = 12;
+ int x = 12;
+ CRect rcClient, rcItem;
+ CWnd* pItem;
+ GetClientRect(&rcClient);
+
+ pItem = GetDlgItem(IDC_LIST_ALARM);
+ pItem->MoveWindow(x, y, rcClient.Width() - x - 12, rcClient.Height() - y - 12);
+*/
+}
\ No newline at end of file
diff --git a/SourceCode/Bond/BondEq/CComponentPLCDlg.h b/SourceCode/Bond/BondEq/CComponentPLCDlg.h
new file mode 100644
index 0000000..b39ac8e
--- /dev/null
+++ b/SourceCode/Bond/BondEq/CComponentPLCDlg.h
@@ -0,0 +1,37 @@
+锘�#pragma once
+#include "CComponentDlg.h"
+
+
+// CComponentPLCDlg 瀵硅瘽妗�
+
+class CComponentPLCDlg : public CComponentDlg
+{
+ DECLARE_DYNAMIC(CComponentPLCDlg)
+
+public:
+ CComponentPLCDlg(CWnd* pParent = nullptr); // 鏍囧噯鏋勯�犲嚱鏁�
+ virtual ~CComponentPLCDlg();
+
+
+private:
+ void InitRxWindows();
+
+private:
+ IObserver* m_pObserver;
+
+
+// 瀵硅瘽妗嗘暟鎹�
+#ifdef AFX_DESIGN_TIME
+ enum { IDD = IDD_COMPONENT_ALARM };
+#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);
+};
diff --git a/SourceCode/Bond/BondEq/Common.h b/SourceCode/Bond/BondEq/Common.h
index 6cc098b..000ad4b 100644
--- a/SourceCode/Bond/BondEq/Common.h
+++ b/SourceCode/Bond/BondEq/Common.h
@@ -73,6 +73,8 @@
#define TREE_BADGE2_BACKGROUND RGB(255, 127, 39)
#define TREE_BADGE2_FOREGROUND RGB(222, 222, 222)
#define HOMEPAGE_BACKGROUND RGB(252, 252, 255)
+#define COMPONENT_DLG_BACKGROUND RGB(252, 252, 255)
+#define COMPONENTS_PLC_BACKGROUND RGB(0, 252, 255)
/* 按钮颜色定义 风格1*/
diff --git a/SourceCode/Bond/BondEq/Resource.h b/SourceCode/Bond/BondEq/Resource.h
index 88fd4b3..77f1666 100644
--- a/SourceCode/Bond/BondEq/Resource.h
+++ b/SourceCode/Bond/BondEq/Resource.h
Binary files differ
--
Gitblit v1.9.3