设计数据发送结构实现更复杂的数据发送
重新封装一下这个结构 方便以后扩展
struct COPY_DATA
{
time_t ltime;//时间
unsigned MsgType;//数据类型
unsigned len;
char buff[0x2000];
};
过程略...
到时候就可以屏蔽特定消息
这玩意一个登录数据就这么一大片,肯定是要过滤的
开始写这个小工具...
其实无非就是框架控件的使用
void CSetMsg::OnBnClickedOk()
{
// TODO: 在此添加控件通知处理程序代码
UpdateData(TRUE);
txtTypeName = txtNameArys[lstType.GetCurSel()];
CDialogEx::OnOK();
}
void CSetMsg::SetDatas(CString& _name, CString& _define, CString& _Type, bool _IsTxt)
{
txtName = _name;
txtDefine = _define;
int i = 0;
for ( i = 0; i < 3; i++)
if (txtNameArys[i] == _Type)break;
if (i > 2)i = 0;
IsTxt = _IsTxt;
nsel = i;
//IsTxt = _IsTxt == L"是";
//UpdateData(FALSE);
}
BOOL CDataAnlyDlg::OnCopyData(CWnd* pWnd, COPYDATASTRUCT* p)
{
UpdateData(TRUE);
if (Pause)return CDialogEx::OnCopyData(pWnd, p);
PCOPYDATA pdata = (PCOPYDATA)p->lpData;
struct tm newtime {};
localtime_s(&newtime, &pdata->ltime);//取出时间
int type = p->dwData;
CString _result;
CString _time;
_time.Format(L"%.2d:%.2d%.2d", newtime.tm_hour, newtime.tm_min, newtime.tm_sec);//显示时间
if (MsgType[type])
{
//转换为buff
unsigned char* buff = (unsigned char*)pdata->buff;
CString _tmp;
for (int i = 0; i < pdata->len; i++)
{
_tmp.Format(L"%.2X", buff[i]);
_result = _result + L" " + _tmp;
}
}
else
{
//转换为文本
_result.Format(L"%s", pdata->buff);
}
// TODO: 在此添加消息处理程序代码和/或调用默认值
lstView.InsertItem(0, MsgName[type]);
lstView.SetItemText(0, 2, _result);
lstView.SetItemText(0, 4, _time);
CString wlen;
wlen.Format(L"%d", pdata->len);
lstView.SetItemText(0, 3, wlen);
wlen.Format(L"%X", pdata->MsgType);
lstView.SetItemText(0, 1, wlen);
return CDialogEx::OnCopyData(pWnd, p);
}
UI绘制略。。
细节略。。没啥好说的