| ¶Ô±ÈÐÂÎļþ |
| | |
| | | // CDevicePropertyDlg.cpp: å®ç°æä»¶ |
| | | // |
| | | |
| | | #include "stdafx.h" |
| | | #include "Servo.h" |
| | | #include "afxdialogex.h" |
| | | #include "DevicePropertyDlg.h" |
| | | |
| | | // CDevicePropertyDlg å¯¹è¯æ¡ |
| | | |
| | | IMPLEMENT_DYNAMIC(CDevicePropertyDlg, CDialogEx) |
| | | |
| | | CDevicePropertyDlg::CDevicePropertyDlg(CWnd* pParent /*=nullptr*/, int nDeviceID /*=0*/) |
| | | : CDialogEx(IDD_DIALOG_DEVICE_PROPERTY, pParent), m_nDeviceID(nDeviceID) |
| | | { |
| | | |
| | | } |
| | | |
| | | CDevicePropertyDlg::~CDevicePropertyDlg() |
| | | { |
| | | } |
| | | |
| | | void CDevicePropertyDlg::DoDataExchange(CDataExchange* pDX) |
| | | { |
| | | CDialogEx::DoDataExchange(pDX); |
| | | DDX_Control(pDX, IDC_LIST_DEVICE_PROPERTY, m_listDeviceProperties); |
| | | } |
| | | |
| | | |
| | | BEGIN_MESSAGE_MAP(CDevicePropertyDlg, CDialogEx) |
| | | END_MESSAGE_MAP() |
| | | |
| | | |
| | | // CDevicePropertyDlg æ¶æ¯å¤çç¨åº |
| | | |
| | | |
| | | BOOL CDevicePropertyDlg::OnInitDialog() |
| | | { |
| | | CDialogEx::OnInitDialog(); |
| | | |
| | | // TODO: 卿¤æ·»å é¢å¤çåå§å |
| | | SERVO::CEquipment* pEquipment = theApp.m_model.m_master.getEquipment(m_nDeviceID); |
| | | if (nullptr == pEquipment) { |
| | | LOGI("<设å¤IDï¼%d>è·å设å¤å±æ§å¤±è´¥ã", m_nDeviceID); |
| | | return FALSE; |
| | | } |
| | | |
| | | // ä¿®æ¹å¯¹è¯æ¡æ é¢ |
| | | std::string strDeviceName = pEquipment->getName(); |
| | | SetWindowText(CString(strDeviceName.c_str())); |
| | | |
| | | // è·åææè®¾å¤å±æ§ |
| | | std::vector<std::pair<std::string, std::string>> properties; |
| | | pEquipment->getProperties(properties); |
| | | |
| | | // è·åListCtrlç客æ·åºå |
| | | CRect rect; |
| | | m_listDeviceProperties.GetClientRect(&rect); |
| | | int nTotalWidth = rect.Width(); |
| | | |
| | | int nColumnWidth = 150; |
| | | m_listDeviceProperties.InsertColumn(0, _T("åç§°"), LVCFMT_LEFT, nColumnWidth); |
| | | m_listDeviceProperties.InsertColumn(1, _T("å¼"), LVCFMT_LEFT, nColumnWidth); |
| | | |
| | | // éå容å¨ä¸çææå±æ§å¹¶è¾åº |
| | | int nItem = 0; |
| | | for (const auto& property : properties) { |
| | | // æå
¥è®¾å¤å±æ§ |
| | | m_listDeviceProperties.InsertItem(nItem, property.first.c_str()); |
| | | m_listDeviceProperties.SetItemText(nItem, 1, property.second.c_str()); |
| | | ++nItem; |
| | | } |
| | | |
| | | // 设置第äºå宽度 |
| | | m_listDeviceProperties.SetColumnWidth(1, nTotalWidth - nColumnWidth); |
| | | |
| | | return TRUE; // return TRUE unless you set the focus to a control |
| | | // å¼å¸¸: OCX 屿§é¡µåºè¿å FALSE |
| | | } |