在CView上显示文字和线 之类

ContractedBlock.gif ExpandedBlockStart.gif 代码
 
   
// 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

 

运行结果:

2010041221261286.png

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值