LAPTOP-SNT8I5JK\Boounion
2025-05-09 1e7d3ca649456469440d74fabfc16e191433f9b4
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
127
128
129
130
131
132
133
134
135
136
137
138
139
// CPagePortProperty.cpp: 实现文件
//
 
#include "stdafx.h"
#include "Servo.h"
#include "CPagePortProperty.h"
#include "afxdialogex.h"
 
 
// CPagePortProperty 对话框
 
IMPLEMENT_DYNAMIC(CPagePortProperty, CHMPropertyPage)
 
CPagePortProperty::CPagePortProperty(CWnd* pParent /*=nullptr*/)
    : CHMPropertyPage(IDD_PAGE_PORT_PROPERTY, pParent)
{
    m_pPort = nullptr;
}
 
CPagePortProperty::~CPagePortProperty()
{
}
 
void CPagePortProperty::DoDataExchange(CDataExchange* pDX)
{
    CHMPropertyPage::DoDataExchange(pDX);
}
 
 
BEGIN_MESSAGE_MAP(CPagePortProperty, CHMPropertyPage)
    ON_WM_CTLCOLOR()
    ON_WM_DESTROY()
    ON_WM_SIZE()
    ON_BN_CLICKED(IDC_CHECK_ENABLE, &CPagePortProperty::OnBnClickedCheckEnable)
END_MESSAGE_MAP()
 
 
// CPagePortProperty 消息处理程序
void CPagePortProperty::setLoadPort(SERVO::CLoadPort* pPort)
{
    m_pPort = pPort;
}
 
BOOL CPagePortProperty::OnInitDialog()
{
    CHMPropertyPage::OnInitDialog();
 
 
    ASSERT(m_pPort);
    CComboBox* pComboBox;
    std::string strTemp;
 
    
    pComboBox = (CComboBox*)GetDlgItem(IDC_COMBO_PORT_TYPE);
    for (int i = 1; i <= 7; i++) {
        pComboBox->InsertString(i - 1, SERVO::CLoadPort::getPortTypeDescription(i, strTemp).c_str());
    }
    int portType = m_pPort->getPortType();
    if (1 <= portType && portType <= 7) {
        pComboBox->SetCurSel(portType - 1);
    }
 
    pComboBox = (CComboBox*)GetDlgItem(IDC_COMBO_PORT_MODE);
    for (int i = 1; i <= 3; i++) {
        pComboBox->InsertString(i - 1, SERVO::CLoadPort::getPortModeDescription(i, strTemp).c_str());
    }
    int portMode = m_pPort->getPortMode();
    if (1 <= portMode && portMode <= 3) {
        pComboBox->SetCurSel(portMode - 1);
    }
 
    pComboBox = (CComboBox*)GetDlgItem(IDC_COMBO_PORT_CASSERT_TYPE);
    for (int i = 1; i <= 3; i++) {
        pComboBox->InsertString(i - 1, SERVO::CLoadPort::getPortCassetteTypeDescription(i, strTemp).c_str());
    }
    int cessetteType = m_pPort->getCessetteType();
    if (1 <= cessetteType && cessetteType <= 3) {
        pComboBox->SetCurSel(cessetteType - 1);
    }
 
    pComboBox = (CComboBox*)GetDlgItem(IDC_COMBO_PORT_TRANSFER_MODE);
    for (int i = 1; i <= 3; i++) {
        pComboBox->InsertString(i - 1, SERVO::CLoadPort::getPortTransferModeDescription(i, strTemp).c_str());
    }
    int transferMode = m_pPort->getTransferMode();
    if (1 <= transferMode && transferMode <= 3) {
        pComboBox->SetCurSel(transferMode - 1);
    }
 
    ((CButton*)GetDlgItem(IDC_CHECK_AUTO_CHANGE))->SetCheck(m_pPort->isAutoChange() ? BST_CHECKED : BST_UNCHECKED);
    
    
    
    EnableCtrls(m_pPort->isEnable());
 
 
 
    return TRUE;  // return TRUE unless you set the focus to a control
                  // 异常: OCX 属性页应返回 FALSE
}
 
HBRUSH CPagePortProperty::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
    HBRUSH hbr = CHMPropertyPage::OnCtlColor(pDC, pWnd, nCtlColor);
 
    // TODO:  在此更改 DC 的任何特性
 
    // TODO:  如果默认的不是所需画笔,则返回另一个画笔
    return hbr;
}
 
void CPagePortProperty::OnDestroy()
{
    CHMPropertyPage::OnDestroy();
 
    // TODO: 在此处添加消息处理程序代码
}
 
void CPagePortProperty::OnSize(UINT nType, int cx, int cy)
{
    CHMPropertyPage::OnSize(nType, cx, cy);
 
    // TODO: 在此处添加消息处理程序代码
}
 
void CPagePortProperty::OnBnClickedCheckEnable()
{
    BOOL bCheck = ((CButton*)GetDlgItem(IDC_CHECK_ENABLE))->GetCheck() == BST_CHECKED;
    EnableCtrls(bCheck);
}
 
void CPagePortProperty::EnableCtrls(BOOL bEnable)
{
    GetDlgItem(IDC_COMBO_PORT_TYPE)->EnableWindow(bEnable);
    GetDlgItem(IDC_COMBO_PORT_MODE)->EnableWindow(bEnable);
    GetDlgItem(IDC_COMBO_PORT_CASSERT_TYPE)->EnableWindow(bEnable);
    GetDlgItem(IDC_COMBO_PORT_TRANSFER_MODE)->EnableWindow(bEnable);
    GetDlgItem(IDC_CHECK_AUTO_CHANGE)->EnableWindow(bEnable);
}