📄 ipdatashow.cpp
字号:
// IpDataShow.cpp : implementation file
//
#include "stdafx.h"
#include "listen.h"
#include "IpDataShow.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CIpDataShow dialog
CIpDataShow::CIpDataShow(CWnd* pParent /*=NULL*/)
: CDialog(CIpDataShow::IDD, pParent)
{
//{{AFX_DATA_INIT(CIpDataShow)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
m_hBkBrush = CreateSolidBrush(RGB(255,255,255));
}
CIpDataShow::~CIpDataShow()
{
DeleteObject(m_hBkBrush);
}
void CIpDataShow::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CIpDataShow)
DDX_Control(pDX, IDC_EDIT3, m_CharEdit);
DDX_Control(pDX, IDC_EDIT2, m_HexEdit);
DDX_Control(pDX, IDC_EDIT1, m_NumEdit);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CIpDataShow, CDialog)
//{{AFX_MSG_MAP(CIpDataShow)
ON_WM_SIZE()
ON_WM_CTLCOLOR()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CIpDataShow message handlers
void CIpDataShow::OnSize(UINT nType, int cx, int cy)
{
CDialog::OnSize(nType, cx, cy);
// TODO: Add your message handler code here
CRect rect;
GetClientRect(&rect);
if(!m_NumEdit.m_hWnd||!m_NumEdit.m_hWnd||!m_NumEdit.m_hWnd)
return;
m_NumEdit.MoveWindow(0,0,40,cy);
m_HexEdit.MoveWindow(50,0,300,cy);
m_CharEdit.MoveWindow(360,0,cx-360,cy);
}
HBRUSH CIpDataShow::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
// TODO: Change any attributes of the DC here
// TODO: Return a different brush if the default is not desired
return m_hBkBrush;
}
//格式化显示IP包
void CIpDataShow::ShowIpData(char *pData, int len)
{
int i;
CString str0 = "";
CString str1 = "";
CString tmp;
int wd = 8;
int width = wd*2;
int lines = len/width;
for(i=0; i<len; i+=width)
{
tmp.Format("%6.6X", i);
if(i+width<len)
tmp+="\r\n";
str0+=tmp;
}
m_NumEdit.SetWindowText(str0);
str0.Empty();
bool flag=false;
if(lines%width!=0)
lines++;
for(int row=0; row<lines; row++)
{
int col;
for(col=0; col<width; col++)
{
i = row*width+col;
if(i>=len)
{
flag = true;
break;
}
tmp.Format("%2.2X ", (unsigned char)pData[i]);
if(col==wd-1)
tmp += " ";
str0 += tmp;
if(pData[i]>=32 && pData[i]<255)
tmp.Format("%c", (unsigned char)pData[i]);
else
tmp.Format(".");
str1 += tmp;
}
if(row<lines-1)
{
str0 += "\r\n";
//str1 += "\r\n";
}
if(flag)
break;
}
m_HexEdit.SetWindowText(str0);
m_CharEdit.SetWindowText(str1);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -