forked from gopa810/gcal-cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDNewCountry.cpp
87 lines (68 loc) · 2.1 KB
/
DNewCountry.cpp
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
// DNewCountry.cpp : implementation file
//
#include "stdafx.h"
#include "vcal5beta.h"
#include "DNewCountry.h"
#include "TCountry.h"
/////////////////////////////////////////////////////////////////////////////
// DNewCountry dialog
DNewCountry::DNewCountry(CWnd* pParent /*=NULL*/)
: CDialog(DNewCountry::IDD, pParent)
{
//{{AFX_DATA_INIT(DNewCountry)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void DNewCountry::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(DNewCountry)
DDX_Control(pDX, IDC_COMBO1, m_wCont);
DDX_Control(pDX, IDC_EDIT2, m_wName);
DDX_Control(pDX, IDC_EDIT1, m_wCode);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(DNewCountry, CDialog)
//{{AFX_MSG_MAP(DNewCountry)
ON_EN_CHANGE(IDC_EDIT1, OnChangeEdit1)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// DNewCountry message handlers
void DNewCountry::OnChangeEdit1()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler code here
CString str;
WORD w = 0xffff;
int bAllow = 0;
m_wCode.GetWindowText(str);
if (str.GetLength() == 2)
{
w = (WORD)((BYTE)(str.GetAt(1) - 'A')) + (WORD)(((BYTE)(str.GetAt(1) - 'A'))<<8);
bAllow = (strlen(TCountry::GetCountryName(w))==0);
}
GetDlgItem(IDOK)->EnableWindow(bAllow);
m_wName.EnableWindow(bAllow);
}
void DNewCountry::OnOK()
{
// TODO: Add extra validation here
m_wCode.GetWindowText(strCode);
m_wName.GetWindowText(strName);
nContinent = m_wCont.GetCurSel();
CDialog::OnOK();
}
BOOL DNewCountry::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
for(int i = 0; i < 8; i++)
m_wCont.AddString(TCountry::gcontinents[i]);
m_wCont.SetCurSel(0);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}