📄 netflow.cpp
字号:
// NetFlow.cpp : implementation file
//
#include "stdafx.h"
#include "sjsys.h"
#include "NetFlow.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CNetFlow dialog
CNetFlow::CNetFlow(CWnd* pParent /*=NULL*/)
: CDialog(CNetFlow::IDD, pParent)
{
//{{AFX_DATA_INIT(CNetFlow)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void CNetFlow::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CNetFlow)
DDX_Control(pDX, IDC_LIST1, m_list);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CNetFlow, CDialog)
//{{AFX_MSG_MAP(CNetFlow)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CNetFlow message handlers
BOOL CNetFlow::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
RECT rect;
int width=0;
m_list.GetWindowRect(&rect);
width=rect.right-rect.left;
m_list.SetExtendedStyle(WS_CHILD|WS_CLIPSIBLINGS|WS_EX_TOOLWINDOW|WS_BORDER|LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES);
m_list.InsertColumn(0,"员工",LVCFMT_LEFT,width/4);
m_list.InsertColumn(1,"IP地址",LVCFMT_LEFT,width/4);
m_list.InsertColumn(2,"输入带宽(kbps)",LVCFMT_LEFT,width/4);
m_list.InsertColumn(2,"输出带宽(kbps)",LVCFMT_LEFT,width/4);
_RecordsetPtr m_pRecordset;
m_pRecordset.CreateInstance(__uuidof(Recordset));
try
{
CString SQLStr="select ID,Devicename,RealInFlow,RealOutFlow from Device order by RealInFlow desc";
m_pRecordset->Open((LPTSTR)SQLStr.GetBuffer(130),
((CSjsysApp*)AfxGetApp())->pConnection.GetInterfacePtr(),
adOpenDynamic,adLockPessimistic,adCmdText);//打开查询结果记录集
int i=0;
int nItem=0;
while(!(m_pRecordset->adoEOF))
{
nItem=m_list.InsertItem(i,(LPCSTR)_bstr_t(m_pRecordset->GetCollect("ID")));//产品编号
m_list.SetItemText(nItem,1,(LPCSTR)_bstr_t(m_pRecordset->GetCollect("Devicename"))); //产品名称
m_list.SetItemText(nItem,2,(LPCSTR)_bstr_t(m_pRecordset->GetCollect("RealInFlow"))); //规格
m_list.SetItemText(nItem,3,(LPCSTR)_bstr_t(m_pRecordset->GetCollect("RealOutFlow"))); //型号
m_pRecordset->MoveNext();
i++;
}
m_pRecordset->Close();
}
catch(_com_error e)///捕捉异常
{
CString errormessage;
MessageBox("创建记录集失败!","错误");
}
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -