-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDlgEditDevice.cpp
More file actions
70 lines (62 loc) · 1.59 KB
/
DlgEditDevice.cpp
File metadata and controls
70 lines (62 loc) · 1.59 KB
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
#include "stdafx.h"
#include "krs.h"
#include "DlgEditDevice.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
DlgEditDevice::DlgEditDevice(SERV_Device* device, CWnd* pParent /*=NULL*/)
: CDialog(DlgEditDevice::IDD, pParent),
m_device(device)
{
//{{AFX_DATA_INIT(DlgEditDevice)
m_string_name = _T(m_device->GetName());
m_to_interval = m_device->m_timeout_interval;
//}}AFX_DATA_INIT
}
void DlgEditDevice::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(DlgEditDevice)
DDX_Control(pDX, IDC_COMBO_ADDR, m_combo_addr);
DDX_Text(pDX, IDC_EDIT_NAME, m_string_name);
DDX_Text(pDX, IDC_EDIT_TIMEOUT, m_to_interval);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(DlgEditDevice, CDialog)
//{{AFX_MSG_MAP(DlgEditDevice)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
void DlgEditDevice::OnOK()
{
if (!UpdateData())
return;
if (m_string_name.IsEmpty())
{
MessageBox("Óñòðîéñòâî íå èìååò èìåíè", "Íåâîçìîæíî ñîçäàòü óñòðîéñòâî");
return;
}
int addr = m_combo_addr.GetCurSel();
if (addr == 0)
{
MessageBox("Óñòðîéñòâî íå èìååò àäðåñà", "Íåâîçìîæíî ñîçäàòü óñòðîéñòâî");
return;
}
SERV_Device* old = m_device->GetCfg()->GetDevice(addr);
if (old != NULL && old != m_device)
{
MessageBox("Óñòðîéñòâî ñ òàêèì àäðåñîì óæå ñóùåñòâóåò", "Íåâîçìîæíî ñîçäàòü óñòðîéñòâî");
return;
}
m_device->SetName(m_string_name);
m_device->SetAddr(addr);
m_device->m_timeout_interval = m_to_interval;
CDialog::OnOK();
}
BOOL DlgEditDevice::OnInitDialog()
{
CDialog::OnInitDialog();
m_combo_addr.SetCurSel(m_device->GetAddr());
return TRUE;
}