// WinPingDlg.cpp : implementation file
//
#include "stdafx.h"
#include "WinPing.h"
#include "WinPingDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
// CAboutDlg dialog used for App About
/////////////////////////////////////////////////////////////////////////////
// WINPING - Developed by Norm Almond, Acknowledgements to Chris Maunder & Lewis Napper
//
// MAINTANENCE LOG:
//
// Version 1.0 - Public Release
//
// Version 1.1 - Fix combo assert in debug
// - Fix repeated string entries in combo
// - Fix Ping times now correct
/////////////////////////////////////////////////////////////////////////////
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
virtual void OnOK();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CWinPingDlg dialog
CWinPingDlg::CWinPingDlg(CWnd* pParent /*=NULL*/)
: CDialog(CWinPingDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CWinPingDlg)
m_strRetry = _T("");
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
m_nDir = 0;
m_nPos = 0;
m_bProgress = FALSE;
}
void CWinPingDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CWinPingDlg)
DDX_Control(pDX, IDC_SPIN1, m_spinner);
DDX_Control(pDX, IDC_LIST, m_list);
DDX_Text(pDX, IDC_RETRIES, m_strRetry);
DDX_Control(pDX, IDC_SERVERS, m_cboServers);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CWinPingDlg, CDialog)
//{{AFX_MSG_MAP(CWinPingDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(ID_PING, OnPing)
ON_WM_TIMER()
ON_BN_CLICKED(ID_ABOUT, OnAbout)
ON_MESSAGE(WM_MSG_STATUS,OnStatus)
ON_MESSAGE(WM_PING_END,OnPingEnd)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CWinPingDlg message handlers
BOOL CWinPingDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Add "About..." menu item to system menu.
CString strHost;
CString str;
int nEntrys = AfxGetApp()->GetProfileInt("MRU","Entries",0);
for (int n=0;n < nEntrys;n++)
{
str.Format("Host#%d",n);
strHost = AfxGetApp()->GetProfileString("MRU",str,"");
m_cboServers.AddString(strHost);
}
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
m_img.Create(IDB_LOG,16,1,RGB(255,0,255));
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
CRect rc;
CWnd* pWnd;
pWnd= GetDlgItem(IDC_FROM);
pWnd->GetWindowRect(rc);
ScreenToClient(rc);
m_ptFrom = rc.BottomRight();
m_ptFrom.x+=5;
pWnd= GetDlgItem(IDC_TO);
pWnd->GetWindowRect(rc);
ScreenToClient(rc);
m_ptTo = CPoint(rc.left,rc.bottom);
m_list.InsertColumn(0,"Status",LVCFMT_LEFT,800);
m_list.SetImageList(&m_img, LVSIL_SMALL);
m_list.GetClientRect(rc);
m_list.SetColumnWidth(0,rc.Width());
m_rcRect.left = m_ptFrom.x;
m_rcRect.right = m_ptTo.x;
m_rcRect.top = m_rcRect.bottom = m_ptFrom.y;
m_rcRect.InflateRect(0,3);
m_spinner.SetRange(1,99);
m_spinner.SetPos(5);
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
}
void CWinPingDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CWinPingDlg::OnPaint()
{
CPaintDC dc(this); // device context for painting
if (IsIconic())
{
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
dc.MoveTo(m_ptFrom);
dc.LineTo(m_ptTo);
if (m_bProgress)
{
CRect rc(m_nPos,m_ptTo.y,m_nPos,m_ptTo.y);
rc.InflateRect(3,3);
CBrush br(RGB(255,0,0));
CBrush* pBrush = dc.SelectObject(&br);
dc.Rectangle(rc);
dc.SelectObject(pBrush);
}
CDialog::OnPaint();
}
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CWinPingDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CWinPingDlg::OnPing()
{
UpdateData(TRUE);
EnableControls(FALSE);
int nRetries = m_spinner.GetPos();
int nCnt = m_list.GetItemCount();
if (nCnt > 0)
{
m_list.InsertItem(nCnt,"",4);
}
CString strHost;
GetDlgItem(IDC_SERVERS)->GetWindowText(strHost);
m_pingThread.StartPing(nRetries,strHost,m_hWnd);
m_nPos = m_ptFrom.x;
m_nDir = 20;
SetTimer(0x1001,100,NULL);
m_bProgress = TRUE;
// nick@shortcuts.net <nick@shortcuts.net>
}
LRESULT CWinPingDlg::OnStatus(WPARAM wParam, LPARAM lParam)
{
char* pMsg = (char*) lParam;
int nCnt = m_list.GetItemCount();
int i = m_list.InsertItem(nCnt,pMsg,wParam);
m_list.EnsureVisible(i,FALSE);
delete pMsg;
return 0;
}
LRESULT CWinPingDlg::OnPingEnd(WPARAM wParam, LPARAM lParam)
{
EnableControls(TRUE);
m_bProgress = FALSE;
InvalidateRect(m_rcRect,TRUE);
KillTimer(0x1001);
if (lParam == 1)
{
CString strHost;
GetDlgItem(IDC_SERVERS)->GetWindowText(strHost);
// Fix duplicate entries
if (m_cboServers.FindStringExact(-1,strHost) == CB_ERR)
m_cboServers.AddString(strHost);
GetDlgItem(IDC_SERVERS)->SetFocus();
}
return 0;
}
void CWinPingDlg::OnTimer(UINT nIDEvent)
{
m_nPos += m_nDir;
InvalidateRect(m_rcRect,TRUE);
if (m_nPos > m_ptTo.x)
{
m_nDir = -20;
m_nPos = m_ptTo.x - 5;
}
if (m_nPos < m_ptFrom.x)
{
m_nDir = +20;
m_nPos = m_ptFrom.x + 5;
}
CDialog::OnTimer(nIDEvent);
}
void CWinPingDlg::OnAbout()
{
CAboutDlg dlg;
if (dlg.DoModal())
{
}
}
void CWinPingDlg::EnableControls(BOOL bEnable)
{
GetDlgItem(IDC_SERVERS)->EnableWindow(bEnable);
GetDlgItem(IDC_RETRIES)->EnableWindow(bEnable);
GetDlgItem(ID_PING)->EnableWindow(bEnable);
}
void CWinPingDlg::OnCancel()
{
CString strHost;
CString str;
int nCnt = m_cboServers.GetCount();
AfxGetApp()->WriteProfileInt("MRU","Entries",nCnt);
for (int n=0;n < nCn
没有合适的资源?快使用搜索试试~ 我知道了~
ping扫描带源码VC++6.0
共39个文件
h:7个
obj:6个
cpp:6个
5星 · 超过95%的资源 需积分: 10 55 下载量 153 浏览量
2010-12-09
14:48:42
上传
评论
收藏 3.39MB RAR 举报
温馨提示
ping扫描带源码VC++6.0 ping扫描带源码VC++6.0 ping扫描带源码VC++6.0 ICMP扫描带源码VC++6.0
资源推荐
资源详情
资源评论
收起资源包目录
WinPing.rar (39个子文件)
WinPing
StdAfx.cpp 209B
WinPing.aps 43KB
WinPingDlg.cpp 8KB
resource.h 1KB
WinPing.rc 7KB
ComboBoxEx.h 1KB
WinPing.h 1KB
PingThread.h 818B
WinPing.ncb 121KB
WinPing.dsw 539B
WinPing.opt 55KB
Debug
PING.obj 15KB
vc60.pdb 356KB
PingThread.obj 7KB
vc60.idb 209KB
WinPing.ilk 2.43MB
ComboBoxEx.obj 12KB
WinPing.pdb 3.42MB
WinPingDlg.obj 41KB
WinPing.exe 2.09MB
WinPing.obj 15KB
StdAfx.obj 104KB
WinPing.res 33KB
WinPing.pch 5.28MB
WinPing.dsp 5KB
PingThread.cpp 2KB
PING.cpp 5KB
StdAfx.h 1KB
ping.h 2KB
ComboBoxEx.cpp 2KB
Release
res
WinPing.rc2 399B
WinPing.ico 766B
bitmap1.bmp 758B
ico00001.ico 10KB
icon1.ico 10KB
WinPing.cpp 2KB
WinPingDlg.h 2KB
WinPing.plg 2KB
WinPing.clw 2KB
共 39 条
- 1
资源评论
- z_alpha2013-05-08嗯,效果不错~thx~
- CathrineL2014-01-08挺好的,实验用了一点
- qiqiweige2012-12-30项目里的一个难题直接用这个就解决了,感谢
- 香槟鱼骨头2012-12-28非常好,有点高级啊,学校实验看着就不是自己的
fei324
- 粉丝: 8
- 资源: 7
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功