在CView上显示文字和线 之类
代码
// view_graph_1View.cpp : implementation of the CView_graph_1View class
//
#include "stdafx.h"
#include "view_graph_1.h"
#include "view_graph_1Doc.h"
#include "view_graph_1View.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CView_graph_1View
IMPLEMENT_DYNCREATE(CView_graph_1View, CView)
BEGIN_MESSAGE_MAP(CView_graph_1View, CView)
//{{AFX_MSG_MAP(CView_graph_1View)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CView_graph_1View construction/destruction
CView_graph_1View::CView_graph_1View()
{
// TODO: add construction code here
}
CView_graph_1View::~CView_graph_1View()
{
}
BOOL CView_graph_1View::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CView_graph_1View drawing
void CView_graph_1View::OnDraw(CDC* pDC)
{
CView_graph_1Doc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
CRect rect;
GetClientRect(rect);//
CString outText="aaaa";
CPen pc1(PS_SOLID, 1, RGB( 0, 125, 128)); //ペンの初期化
CPen pc3(PS_SOLID, 2, RGB( 0, 0, 255));
pDC->SelectObject(&pc3);
pDC->MoveTo(100, 100) ; pDC->LineTo(150, 100);
pDC->TextOut(rect.right/2,rect.bottom/2,outText,sizeof(outText)-1);
}
/////////////////////////////////////////////////////////////////////////////
// CView_graph_1View diagnostics
#ifdef _DEBUG
void CView_graph_1View::AssertValid() const
{
CView::AssertValid();
}
void CView_graph_1View::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CView_graph_1Doc* CView_graph_1View::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CView_graph_1Doc)));
return (CView_graph_1Doc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CView_graph_1View message handlers
运行结果: