summaryrefslogtreecommitdiffabout
path: root/GeneralPage.cpp
authorMichael Krelin <hacker@klever.net>2004-07-05 01:53:09 (UTC)
committer Michael Krelin <hacker@klever.net>2004-07-05 01:53:09 (UTC)
commit955d4e00adc9f39ab93bf21f07506eb75b013c70 (patch) (unidiff)
tree92493a2c9ac206b822e24a9e5a6f6b1589be6afb /GeneralPage.cpp
downloadT42-955d4e00adc9f39ab93bf21f07506eb75b013c70.zip
T42-955d4e00adc9f39ab93bf21f07506eb75b013c70.tar.gz
T42-955d4e00adc9f39ab93bf21f07506eb75b013c70.tar.bz2
initial commit into svn repository
git-svn-id: http://svn.klever.net/kin/T42/trunk@1 fe716a7a-6dde-0310-88d9-d003556173a8
Diffstat (limited to 'GeneralPage.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--GeneralPage.cpp100
1 files changed, 100 insertions, 0 deletions
diff --git a/GeneralPage.cpp b/GeneralPage.cpp
new file mode 100644
index 0000000..78863fc
--- a/dev/null
+++ b/GeneralPage.cpp
@@ -0,0 +1,100 @@
1// GeneralPage.cpp : implementation file
2//
3
4#include "stdafx.h"
5#include "T42.h"
6#include "GeneralPage.h"
7
8#ifdef _DEBUG
9#define new DEBUG_NEW
10#undef THIS_FILE
11static char THIS_FILE[] = __FILE__;
12#endif
13
14/////////////////////////////////////////////////////////////////////////////
15// CGeneralPage property page
16
17IMPLEMENT_DYNCREATE(CGeneralPage, CPropertyPage)
18
19CGeneralPage::CGeneralPage() : CPropertyPage(CGeneralPage::IDD)
20{
21 //{{AFX_DATA_INIT(CGeneralPage)
22 //}}AFX_DATA_INIT
23 m_ntalkPort = 518;
24}
25
26CGeneralPage::~CGeneralPage()
27{
28}
29
30void CGeneralPage::DoDataExchange(CDataExchange* pDX)
31{
32 CPropertyPage::DoDataExchange(pDX);
33 //{{AFX_DATA_MAP(CGeneralPage)
34 DDX_Control(pDX, IDC_NTALKPORTSPIN, m_ntalkSpinCtl);
35 DDX_Control(pDX, IDC_NTALKPORT, m_ntalkPortCtl);
36 //}}AFX_DATA_MAP
37 if(pDX->m_bSaveAndValidate){
38 pDX->PrepareEditCtrl(IDC_NTALKPORT);
39 CString ntp;
40 m_ntalkPortCtl.GetWindowText(ntp);
41 UINT p = atoi(ntp);
42 if(!p){
43 servent* se = getservbyname((LPCTSTR)ntp,"udp");
44 if(se)
45 p = ntohs(se->s_port);
46 else{
47 AfxMessageBox(IDS_FAILVALIDATE_NTALKPORT,MB_OK|MB_ICONSTOP);
48 pDX->Fail();
49 return;
50 }
51 }
52 m_ntalkPort = p;
53 }
54}
55
56
57BEGIN_MESSAGE_MAP(CGeneralPage, CPropertyPage)
58 //{{AFX_MSG_MAP(CGeneralPage)
59 ON_NOTIFY(UDN_DELTAPOS, IDC_NTALKPORTSPIN, OnDeltaposNtalkportspin)
60 //}}AFX_MSG_MAP
61END_MESSAGE_MAP()
62
63/////////////////////////////////////////////////////////////////////////////
64// CGeneralPage message handlers
65
66BOOL CGeneralPage::OnInitDialog()
67{
68 CPropertyPage::OnInitDialog();
69
70 m_ntalkSpinCtl.SetRange(1,min(UD_MAXVAL,65535));
71 m_ntalkSpinCtl.SetPos(m_ntalkPort);
72 SetPortCtl();
73
74 return TRUE; // return TRUE unless you set the focus to a control
75 // EXCEPTION: OCX Property Pages should return FALSE
76}
77
78void CGeneralPage::SetPortCtl()
79{
80servent* se = getservbyport(htons(m_ntalkPort),"udp");
81 if(se)
82 m_ntalkPortCtl.SetWindowText(se->s_name);
83 else{
84 CString tmp;
85 tmp.Format("%u",m_ntalkPort);
86 m_ntalkPortCtl.SetWindowText(tmp);
87 }
88}
89
90void CGeneralPage::OnDeltaposNtalkportspin(NMHDR* pNMHDR, LRESULT* pResult)
91{
92 NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR;
93
94 TRACE3("UD iP %d, iD %d, p %d\n",pNMUpDown->iPos,
95 pNMUpDown->iDelta, m_ntalkSpinCtl.GetPos());
96 m_ntalkPort = pNMUpDown->iPos+pNMUpDown->iDelta;
97 SetPortCtl();
98
99 *pResult = 0;
100}