// 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); */ }