LAPTOP-SNT8I5JK\Boounion
2025-01-09 3175d60b3b6e3f43ae62193743c4017db27005dc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#include "stdafx.h"
#include "PlcView.h"
#include "BoounionPLC.h"
#include "Common.h"
 
 
// CPlcView ¶Ô»°¿ò
 
IMPLEMENT_DYNAMIC(CPlcView, CBaseView)
 
CPlcView::CPlcView(CWnd* pParent /*=nullptr*/)
    : CBaseView(IDD_VIEW_PLC, pParent)
{
    m_pObserver = nullptr;
    m_crBkgnd = PLC_VIEW_BACKGROUND;
    m_hbrBkgnd = nullptr;
    m_pPlc = nullptr;
}
 
 
CPlcView::~CPlcView()
{
}
 
void CPlcView::DoDataExchange(CDataExchange* pDX)
{
    CBaseView::DoDataExchange(pDX);
}
 
 
BEGIN_MESSAGE_MAP(CPlcView, CBaseView)
    ON_WM_CTLCOLOR()
    ON_WM_DESTROY()
    ON_WM_SIZE()
END_MESSAGE_MAP()
 
// CComponentData1Dlg ÏûÏ¢´¦Àí³ÌÐò
 
void CPlcView::SetContext(void* pContext)
{
    CBaseView::SetContext(pContext);
 
    if (::IsWindow(m_hWnd) && m_pContext != nullptr) {
        SetDlgItemText(IDC_LABEL_PLC_NAME, ((CPLC*)m_pContext)->getName().c_str());
    }
}
 
void CPlcView::InitRxWindows()
{
    /* code */
    // ¶©ÔÄÊý¾Ý
    IRxWindows* pRxWindows = RX_GetRxWindows();
    if (m_pObserver == NULL) {
        m_pObserver = pRxWindows->allocObserver([&](IAny* pAny) -> void {
            // onNext
            pAny->addRef();
            int code = pAny->getCode();
 
            pAny->release();
        }, [&]() -> void {
            // onComplete
        }, [&](IThrowable* pThrowable) -> void {
            // onErrorm
            pThrowable->printf();
        });
 
        theApp.m_model.getObservable()->observeOn(pRxWindows->mainThread())
            ->subscribe(m_pObserver);
    }
}
 
BOOL CPlcView::OnInitDialog()
{
    CBaseView::OnInitDialog();
 
    if (m_pContext != nullptr) {
        SetDlgItemText(IDC_LABEL_PLC_NAME, ((CPLC*)m_pContext)->getName().c_str());
    }
 
    return TRUE;  // return TRUE unless you set the focus to a control
                  // Òì³£: OCX ÊôÐÔÒ³Ó¦·µ»Ø FALSE
}
 
 
HBRUSH CPlcView::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
    HBRUSH hbr = CBaseView::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 CPlcView::OnDestroy()
{
    CBaseView::OnDestroy();
 
    if (m_hbrBkgnd != nullptr) {
        ::DeleteObject(m_hbrBkgnd);
    }
 
    if (m_pObserver != NULL) {
        m_pObserver->unsubscribe();
        m_pObserver = NULL;
    }
}
 
void CPlcView::OnSize(UINT nType, int cx, int cy)
{
    CBaseView::OnSize(nType, cx, cy);
}
 
void CPlcView::Resize()
{
    int y = 12;
    int x = 0;
    CRect rcClient, rcItem;
    CWnd* pItem;
    GetClientRect(&rcClient);
}