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