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

📄 nmsinfonet.cpp

📁 我们的网管程序的后台软件,主要是网络方面的内容.
💻 CPP
字号:
// NMSInfoNet.cpp : implementation file
//

#include "stdafx.h"
#include "..\nms.h"
#include "NMSInfoNet.h"

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

/////////////////////////////////////////////////////////////////////////////
// CNMSInfoNet dialog

extern CBrush *g_pWhiteBrush;			/* 背景颜色 */

CNMSInfoNet::CNMSInfoNet(CWnd* pParent /*=NULL*/)
	: CDialog(CNMSInfoNet::IDD, pParent)
{
	//{{AFX_DATA_INIT(CNMSInfoNet)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
}


void CNMSInfoNet::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CNMSInfoNet)
	DDX_Control(pDX, IDC_CHECK_BYTEORDER, m_ByteOrder);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CNMSInfoNet, CDialog)
	//{{AFX_MSG_MAP(CNMSInfoNet)
	ON_WM_CTLCOLOR()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CNMSInfoNet message handlers

BOOL CNMSInfoNet::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	GetLocalHostIFList();	

	/* Current Used Protocol */
	CComboBox *pComBox = (CComboBox *)GetDlgItem(IDC_PROTOCOL_USED);
	if(pComBox != 0)
	{
		pComBox->ResetContent();
		pComBox->InsertString(PROTOCOL_SNMP , "Snmp Protocol");
		pComBox->InsertString(PROTOCOL_NOT_SNMP , "Snmp Not Used");
		pComBox->SetCurSel(pApp->m_ProtocolUsed);
	}

	if(pApp->bByteOrderChange)
	{
		m_ByteOrder.SetCheck(1);
	}
	else
	{
		m_ByteOrder.SetCheck(0);
	}

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}


BOOL CNMSInfoNet::GetLocalHostIFList()
{
	char   LocalHostName[MAX_IP_LEN+1];
	struct hostent *pLocalHost;

	int		i;

	struct in_addr	in;

	CComboBox 	*pComBox=(CComboBox *)GetDlgItem(IDC_SNMP_SEND_IP);

	WORD wVersionRequested;
	WSADATA wsaData;

	if(pComBox == NULL)
	{
		return FALSE;
	}	

	wVersionRequested = MAKEWORD( 2, 2 );
 
	/*
	 *		Start 
	*/
	if( WSAStartup( wVersionRequested, &wsaData ) != 0)
	{
		return FALSE;
	}

	/*
	 *		get Local host IP 
	*/
	if( gethostname (LocalHostName , MAX_IP_LEN) < 0)
	{
		return FALSE;
	}
	pLocalHost = gethostbyname (LocalHostName);

	for(i=0; pLocalHost&&pLocalHost->h_addr_list[i]; i++)
	{
		/*
		*		Addresses are returned in network byte order
		*/
		memcpy((void*)&in.S_un.S_addr, (void*)(pLocalHost->h_addr_list[i]) , 4);
		strcpy(LocalHostName , inet_ntoa(in));

		pComBox->InsertString(i , LocalHostName);
		pComBox->SetItemData(i , in.S_un.S_addr);

	}

	pComBox->SetCurSel(0);


	return TRUE;
}


void CNMSInfoNet::NetInfoSave()
{
	/* Current Used Protocol Changed? */
	CComboBox *pComBox = (CComboBox *)GetDlgItem(IDC_PROTOCOL_USED);
	int		iProtocol=0;
	if(pComBox != 0)
	{
		iProtocol=pComBox->GetCurSel();
		if(pApp->m_ProtocolUsed != iProtocol)
		{
			if( MessageConfirmBox("改变当前通讯协议") == TRUE)
			{
				pApp->m_ProtocolUsed = iProtocol;
			}
		}
	}

	if(m_ByteOrder.GetCheck())
	{
		pApp->bByteOrderChange = TRUE;
	}
	else
	{
		pApp->bByteOrderChange = FALSE;
	}
}

HBRUSH CNMSInfoNet::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) 
{
	HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
	
	pDC->SetBkMode(TRANSPARENT);
	return (HBRUSH)g_pWhiteBrush->m_hObject;
	
}

⌨️ 快捷键说明

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