⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cepingdlg.cpp

📁 Ping test program based on windows ce
💻 CPP
字号:
// cepingDlg.cpp : implementation file
//

#include "stdafx.h"
#include "ceping.h"
#include "cepingDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CCepingDlg dialog

CCepingDlg::CCepingDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CCepingDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CCepingDlg)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
	// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CCepingDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CCepingDlg)
	DDX_Control(pDX, IDC_COMBO1, m_combo);
	DDX_Control(pDX, IDC_EDIT4, m_editwait);
	DDX_Control(pDX, IDC_EDIT3, m_editttl);
	DDX_Control(pDX, IDC_EDIT2, m_editntimes);
	DDX_Control(pDX, IDC_STATIC_NAME, m_stname);
	DDX_Control(pDX, IDC_EDIT1, m_editname);
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CCepingDlg, CDialog)
	//{{AFX_MSG_MAP(CCepingDlg)
	ON_BN_CLICKED(IDC_PING_OK, OnPingOk)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CCepingDlg message handlers

BOOL CCepingDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	// 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
	
	CenterWindow(GetDesktopWindow());	// center to the hpc screen

	// TODO: Add extra initialization here
	m_editwait.SetLimitText( 4 ) ;
	m_editttl.SetLimitText( 3 ) ;
	m_editntimes.SetLimitText( 2 ) ;

	m_editwait.SetWindowText(TEXT("1000") );
	m_editttl.SetWindowText(TEXT("128") );
	m_editntimes.SetWindowText( TEXT("5") );
	m_editname.SetWindowText( TEXT("192.168.81.11") ) ;
	return TRUE;  // return TRUE  unless you set the focus to a control
}


extern "C"  int Ping( TCHAR *Address , int iTtl , int iWaitTime , TCHAR *szName , int *pttl) ;

void CCepingDlg::OnPingOk() 
{
	// TODO: Add your control notification handler code here
	TCHAR szHost  [ MAX_PATH ]  = { TEXT( "" ) }  ;
	TCHAR szName  [ MAX_PATH ]  = { TEXT( "" ) }  ;
	TCHAR szWait  [ 5 ]  = { TEXT( "" ) }  ;
	TCHAR szTtl   [ 4 ]  = { TEXT( "" ) }  ;
	TCHAR szNTime [ 3 ]  = { TEXT( "" ) }  ;
	TCHAR szRes   [ 50 ] ; 
	int iRes , rtt ;

	m_stname.SetWindowText( TEXT( "" ) ) ;
	m_combo.ResetContent() ;
	m_editname.GetWindowText( szHost , 17 ) ;
	m_editwait.GetWindowText( szWait , sizeof(szWait)/sizeof(TCHAR) ) ;
	int wait = _ttoi( szWait ) ;
	if( wait <0 || wait>9999 )
	{
		wait = 1000 ; 
	    m_editwait.SetWindowText(TEXT("1000") );
	}
	m_editttl.GetWindowText( szTtl , sizeof(szTtl)/sizeof(TCHAR) ) ;
	int ttl = _ttoi( szTtl ) ;
	if( ttl < 0 || ttl > 999 )
	{
		ttl =128 ;
	    m_editttl.SetWindowText(TEXT("128") );
	}
	m_editntimes.GetWindowText( szNTime , sizeof(szNTime)/sizeof(TCHAR)  ) ;
	int ntimes = _ttoi( szNTime ) ;
	if( ntimes < 0 || ntimes > 99 )
	{
		ntimes = 1 ;
	    m_editntimes.SetWindowText( TEXT("1") );
	}
	for( int i = 0 ; i < ntimes ; i++ )
	{
	    iRes = Ping( szHost , ttl , wait  , szName , &rtt ) ;
		if( 0 == i )
	        m_stname.SetWindowText( szName ) ;
		if( -1 == iRes )
		    _stprintf( szRes , TEXT( "%2d : %s" ) , i+1 , TEXT( "Wrong Name" ) ) ;
		else
			if( 0 == iRes )
		        _stprintf( szRes , TEXT( "%2d : %s" ) , i+1 , TEXT( "Request timed out" ) ) ;
			else
		        _stprintf( szRes , TEXT( "%2d : %s %3d ms" ) , i+1 , TEXT("ping OK") , rtt ) ;
		m_combo.AddString( szRes ) ;
	}
	m_combo.SetCurSel(0);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -