summaryrefslogtreecommitdiffabout
path: root/HostProperties.cpp
Unidiff
Diffstat (limited to 'HostProperties.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--HostProperties.cpp185
1 files changed, 185 insertions, 0 deletions
diff --git a/HostProperties.cpp b/HostProperties.cpp
new file mode 100644
index 0000000..6c2a47b
--- a/dev/null
+++ b/HostProperties.cpp
@@ -0,0 +1,185 @@
1// HostProperties.cpp : implementation file
2//
3
4#include "stdafx.h"
5#include "Dipstick.h"
6#include "HostProperties.h"
7#include "DipstickDlg.h"
8
9#ifdef _DEBUG
10#define new DEBUG_NEW
11#undef THIS_FILE
12static char THIS_FILE[] = __FILE__;
13#endif
14
15/////////////////////////////////////////////////////////////////////////////
16// CHostProperties dialog
17
18
19CHostProperties::CHostProperties(CWnd* pParent /*=NULL*/)
20 : CDialog(CHostProperties::IDD, pParent)
21{
22 //{{AFX_DATA_INIT(CHostProperties)
23 m_Host = _T("");
24 m_IP = _T("");
25 m_Loss = _T("");
26 m_Status = _T("");
27 m_Times = _T("");
28 m_URL = _T("");
29 //}}AFX_DATA_INIT
30}
31
32
33void CHostProperties::DoDataExchange(CDataExchange* pDX)
34{
35 CDialog::DoDataExchange(pDX);
36 //{{AFX_DATA_MAP(CHostProperties)
37 DDX_Control(pDX, IDC_STATE, m_StateCtl);
38 DDX_Control(pDX, IDC_URLCAPTION, m_URLCaptionCtl);
39 DDX_Control(pDX, IDC_URL, m_URLCtl);
40 DDX_Control(pDX, IDC_TIMESCAPTION, m_TimesCaptionCtl);
41 DDX_Control(pDX, IDC_TIMES, m_TimesCtl);
42 DDX_Control(pDX, IDC_STATUSCAPTION, m_StatusCaptionCtl);
43 DDX_Control(pDX, IDC_STATUS, m_StatusCtl);
44 DDX_Control(pDX, IDC_OPENURL, m_OpenURLCtl);
45 DDX_Control(pDX, IDC_LOSSCAPTION, m_LossCaptionCtl);
46 DDX_Control(pDX, IDC_LOSS, m_LossCtl);
47 DDX_Control(pDX, IDC_IPCAPTION, m_IPCaptionCtl);
48 DDX_Control(pDX, IDC_IP, m_IPCtl);
49 DDX_Control(pDX, IDC_HOSTCAPTION, m_HostCaptionCtl);
50 DDX_Control(pDX, IDC_HOST, m_HostCtl);
51 DDX_Text(pDX, IDC_HOST, m_Host);
52 DDX_Text(pDX, IDC_IP, m_IP);
53 DDX_Text(pDX, IDC_LOSS, m_Loss);
54 DDX_Text(pDX, IDC_STATUS, m_Status);
55 DDX_Text(pDX, IDC_TIMES, m_Times);
56 DDX_Text(pDX, IDC_URL, m_URL);
57 //}}AFX_DATA_MAP
58}
59
60
61BEGIN_MESSAGE_MAP(CHostProperties, CDialog)
62 //{{AFX_MSG_MAP(CHostProperties)
63 ON_BN_CLICKED(IDC_OPENURL, OnOpenurl)
64 ON_WM_HELPINFO()
65 //}}AFX_MSG_MAP
66END_MESSAGE_MAP()
67
68/////////////////////////////////////////////////////////////////////////////
69// CHostProperties message handlers
70
71BOOL CHostProperties::OnInitDialog()
72{
73 CDialog::OnInitDialog();
74
75 ASSERT(host);
76 if(host->m_HostName.IsEmpty()){
77 m_HostCtl.ShowWindow(SW_HIDE);
78 m_HostCaptionCtl.ShowWindow(SW_HIDE);
79 }else
80 m_Host = host->m_HostName;
81 if(host->m_IP)
82 m_IP = inet_ntoa(*(in_addr*)&host->m_IP);
83 else{
84 m_IPCtl.ShowWindow(SW_HIDE);
85 m_IPCaptionCtl.ShowWindow(SW_HIDE);
86 }
87 if(host->m_Pinged){
88 m_Loss.Format(IDS_FMT_LOSS,host->m_Packetloss);
89 m_Times.Format(IDS_FMT_TIMES,host->m_MinRTT,host->m_AvgRTT,host->m_MaxRTT);
90 }else{
91 m_LossCtl.ShowWindow(SW_HIDE);
92 m_LossCaptionCtl.ShowWindow(SW_HIDE);
93 m_TimesCtl.ShowWindow(SW_HIDE);
94 m_TimesCaptionCtl.ShowWindow(SW_HIDE);
95 }
96 if(host->m_URL.IsEmpty()){
97 m_URLCtl.ShowWindow(SW_HIDE);
98 m_URLCaptionCtl.ShowWindow(SW_HIDE);
99 m_OpenURLCtl.ShowWindow(SW_HIDE);
100 }else
101 m_URL = host->m_URL;
102 if(host->m_Status.IsEmpty()){
103 m_StatusCtl.ShowWindow(SW_HIDE);
104 m_StatusCaptionCtl.ShowWindow(SW_HIDE);
105 }else
106 m_Status = host->m_Status;
107
108 // CG: The following block was added by the ToolTips component.
109 {
110 // Create the ToolTip control.
111 m_tooltip.Create(this);
112 m_tooltip.Activate(TRUE);
113
114 m_tooltip.AddTool(&m_HostCaptionCtl,IDC_HOSTCAPTION);
115 m_tooltip.AddTool(&m_HostCtl,IDC_HOST);
116 m_tooltip.AddTool(&m_IPCaptionCtl,IDC_IPCAPTION);
117 m_tooltip.AddTool(&m_IPCtl,IDC_IPCAPTION);
118 m_tooltip.AddTool(&m_LossCaptionCtl,IDC_LOSSCAPTION);
119 m_tooltip.AddTool(&m_LossCtl,IDC_LOSS);
120 m_tooltip.AddTool(&m_OpenURLCtl,IDC_OPENURL);
121 m_tooltip.AddTool(&m_StatusCaptionCtl,IDC_STATUSCAPTION);
122 m_tooltip.AddTool(&m_StatusCtl,IDC_STATUS);
123 m_tooltip.AddTool(&m_TimesCaptionCtl,IDC_TIMESCAPTION);
124 m_tooltip.AddTool(&m_TimesCtl,IDC_TIMES);
125 m_tooltip.AddTool(&m_URLCaptionCtl,IDC_URLCAPTION);
126 m_tooltip.AddTool(&m_URLCtl,IDC_URL);
127 m_tooltip.AddTool(GetDlgItem(IDOK),IDS_TIP_PROPSOK);
128
129 if(host->m_Pinging){
130 m_StateCtl.SetIcon(AfxGetApp()->LoadIcon(IDI_PINGING));
131 m_tooltip.AddTool(&m_StateCtl,IDS_TIP_PINGING);
132 }else{
133 if(host->m_bToPing){
134 m_StateCtl.SetIcon(AfxGetApp()->LoadIcon(IDI_PENDING));
135 m_tooltip.AddTool(&m_StateCtl,IDS_TIP_PENDING);
136 }else{
137 if(host->m_Pinged){
138 if(host->m_Packetloss==100){
139 m_StateCtl.SetIcon(AfxGetApp()->LoadIcon(IDI_UNREACHABLE));
140 m_tooltip.AddTool(&m_StateCtl,IDS_TIP_UNREACHABLE);
141 }else{
142 m_StateCtl.SetIcon(AfxGetApp()->LoadIcon(IDI_COMPLETED));
143 m_tooltip.AddTool(&m_StateCtl,IDS_TIP_COMPLETE);
144 }
145 }else{
146 m_StateCtl.SetIcon(AfxGetApp()->LoadIcon(IDI_PENDING));
147 m_tooltip.AddTool(&m_StateCtl,IDS_TIP_PENDING);
148 }
149 }
150 }
151
152 UpdateData(FALSE);
153
154 }
155 return TRUE; // return TRUE unless you set the focus to a control
156 // EXCEPTION: OCX Property Pages should return FALSE
157}
158
159void CHostProperties::SetHost(CPingyHost *host)
160{
161 CHostProperties::host = host;
162}
163
164void CHostProperties::OnOpenurl()
165{
166 ASSERT(!m_URL.IsEmpty());
167 ShellExecute(::GetDesktopWindow(),"open",m_URL,NULL,NULL,SW_SHOWMAXIMIZED);
168}
169
170BOOL CHostProperties::PreTranslateMessage(MSG* pMsg)
171{
172 // CG: The following block was added by the ToolTips component.
173 {
174 // Let the ToolTip process this message.
175 m_tooltip.RelayEvent(pMsg);
176
177 return CDialog::PreTranslateMessage(pMsg);
178 }
179}
180
181BOOL CHostProperties::OnHelpInfo(HELPINFO* pHelpInfo)
182{
183 WinHelp(IDD|0x20000l);
184 return TRUE;
185}