stview.cpp
来自「故障诊断工作涉及的领域相当广泛」· C++ 代码 · 共 116 行
CPP
116 行
// stview.cpp : implementation file
//
#include "stdafx.h"
#include "richtest.h"
#include "stview.h"
#include "richtestDoc.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// stview
IMPLEMENT_DYNCREATE(stview, CView)
stview::stview()
{
}
stview::~stview()
{
}
BEGIN_MESSAGE_MAP(stview, CView)
//{{AFX_MSG_MAP(stview)
// NOTE - the ClassWizard will add and remove mapping macros here.
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// stview drawing
void stview::OnDraw(CDC* pDC)
{
const CRichtestDoc* pDoc =(CRichtestDoc*) GetDocument();
// TODO: add draw code here
if(pDoc->total_count!=0)
{int i,hight=0;
for(i=0;i<pDoc->total_count;i++)
{
hight=mydata_draw(pDC,pDoc->pdata+i,hight);
}
}
}
int stview::mydata_draw(CDC *pDC, mydata *data,int hight)
{CString info="信息 :";
CString content(data->buffer,data->the_info_length);
info+=content;
pDC->TextOut(0,hight,info);
hight+=16;
info="类型:";
if(data->the_type==type_char)
{ content="字符";
}
else if(data->the_type==type_short)
{ content="双字";
}
else if(data->the_type==type_int)
{ content="整数";
}
else if(data->the_type==type_double)
{ content="小数";
}
info+=content;
pDC->TextOut(0,hight,info);
hight+=16;
info="数量:";
content.Format("%d",data->the_length);
info+=content;
pDC->TextOut(0,hight,info);
hight+=16;
info="数据:";
for(int i=0;i<data->the_length;i++)
{ if(data->the_type==type_char)
content.Format("%d,",*(data->data.ch+i));
else if(data->the_type==type_short)
content.Format("%d,",*(data->data.sh+i));
else if(data->the_type==type_int)
content.Format("%d,",*(data->data.in+i));
else if(data->the_type==type_double)
content.Format("%f,",*(data->data.dou+i));
info+=content;
}
pDC->TextOut(0,hight,info);
hight+=16;
return hight;
}
/////////////////////////////////////////////////////////////////////////////
// stview diagnostics
#ifdef _DEBUG
void stview::AssertValid() const
{
CView::AssertValid();
}
void stview::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// stview message handlers
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?