📄 vcmat1view.cpp
字号:
// VCmat1View.cpp : implementation of the CVCmat1View class
//
#include "stdafx.h"
#include "VCmat1.h"
#include "VCmat1Doc.h"
#include "VCmat1View.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CVCmat1View
IMPLEMENT_DYNCREATE(CVCmat1View, CView)
BEGIN_MESSAGE_MAP(CVCmat1View, CView)
//{{AFX_MSG_MAP(CVCmat1View)
ON_COMMAND(ID_Menu_MatFileData, OnMenuMatFileData)
ON_COMMAND(ID_Menu_CFileData, OnMenuCFileData)
ON_WM_PAINT()
//}}AFX_MSG_MAP
// Standard printing commands
ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CVCmat1View construction/destruction
CVCmat1View::CVCmat1View()
{
// TODO: add construction code here
}
CVCmat1View::~CVCmat1View()
{
}
BOOL CVCmat1View::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CVCmat1View drawing
void CVCmat1View::OnDraw(CDC* pDC)
{
// TODO: add draw code for native data here
}
/////////////////////////////////////////////////////////////////////////////
// CVCmat1View printing
BOOL CVCmat1View::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CVCmat1View::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CVCmat1View::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CVCmat1View diagnostics
#ifdef _DEBUG
void CVCmat1View::AssertValid() const
{
CView::AssertValid();
}
void CVCmat1View::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CVCmat1Doc* CVCmat1View::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CVCmat1Doc)));
return (CVCmat1Doc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CVCmat1View message handlers
void CVCmat1View::OnMenuMatFileData()
{ Invalidate(TRUE);//////////////////////重绘窗口
CVCmat1Doc* pDoc=GetDocument();////////取得Doc文档句柄
ASSERT_VALID(pDoc);
CPaintDC dc(this);////////////////////取得上下文设备
dc.SetBkMode(TRANSPARENT); /////设置字体
dc.SetTextColor(RGB(0,155,155));
LOGFONT logfont;
memset(&logfont,0,sizeof(logfont));
logfont.lfWeight=20;
logfont.lfHeight=20;
lstrcpy(logfont.lfFaceName,"黑体");
CFont nowFont;
nowFont.CreateFontIndirect(&logfont);
dc.SelectObject(&nowFont);
//////////////////////////将mat文件中取得的数据输出到view窗口中
CString str; double *pii; int i,j;
pii=mxGetPr(pDoc->m_x);
str.Format("Input m_x : %7.2f",*pii); dc.TextOut(10,10,str);
str.Format("Input m_A : "); dc.TextOut(10,10+logfont.lfHeight,str);
pii=mxGetPr(pDoc->m_A);
for(i=0;i<pDoc->n;i++)
{str.Format(" %7.2f",*(pii+i));
dc.TextOut(100+i*3*logfont.lfWeight,10+logfont.lfHeight,str);
}
str.Format("Input m_AB: "); dc.TextOut(10,10+2*logfont.lfHeight,str);
pii=mxGetPr(pDoc->m_AB);
for(i=0;i<pDoc->m;i++)for(j=0;j<pDoc->n;j++)
{str.Format(" %7.2f",*(pii+j*pDoc->m+i));
dc.TextOut(100+j*3*logfont.lfWeight,10+3*logfont.lfHeight+i*logfont.lfHeight,str);
}
}
void CVCmat1View::OnMenuCFileData()
{
Invalidate(TRUE);//////////////////////重绘窗口
CVCmat1Doc* pDoc=GetDocument();////////取得Doc文档句柄
ASSERT_VALID(pDoc);
CPaintDC dc(this);////////////////////取得上下文设备
dc.SetBkMode(TRANSPARENT); /////设置字体
dc.SetTextColor(RGB(255,0,0));
LOGFONT logfont;
memset(&logfont,0,sizeof(logfont));
logfont.lfWeight=20;
logfont.lfHeight=20;
lstrcpy(logfont.lfFaceName,"隶书");
CFont nowFont;
nowFont.CreateFontIndirect(&logfont);
dc.SelectObject(&nowFont);
//////////////////////////将CFile文件中取得的数据输出到view窗口中
CString str; int i,j;
str.Format("Input c_x : %7.2f",pDoc->c_x); dc.TextOut(10,10,str);
str.Format("Input c_A : "); dc.TextOut(10,10+logfont.lfHeight,str);
for(i=0;i<pDoc->n;i++)
{str.Format(" %7.2f",pDoc->c_A[i]);
dc.TextOut(100+i*3*logfont.lfWeight,10+logfont.lfHeight,str);
}
str.Format("Input c_AB: "); dc.TextOut(10,10+2*logfont.lfHeight,str);
for(i=0;i<pDoc->m;i++)for(j=0;j<pDoc->n;j++)
{str.Format(" %7.2f",pDoc->c_AB[i][j]);
dc.TextOut(100+j*3*logfont.lfWeight,10+3*logfont.lfHeight+i*logfont.lfHeight,str);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -