我想用pDC画一个带箭头的线段用哪个函数呀?

解决方案 »

  1.   

    都用->
    画一条直线,然后在moveto顶点,
    lineto箭头一角
    moveto 顶点
    lineto箭关另一角
      

  2.   

    下面是源程序:已经实现了你想要的功能
    只需要看OnDraw()函数就可以了。
    // ttView.cpp : implementation of the CTtView class
    //#include "stdafx.h"
    #include "tt.h"#include "ttDoc.h"
    #include "ttView.h"#ifdef _DEBUG
    #define new DEBUG_NEW
    #undef THIS_FILE
    static char THIS_FILE[] = __FILE__;
    #endif/////////////////////////////////////////////////////////////////////////////
    // CTtViewIMPLEMENT_DYNCREATE(CTtView, CView)BEGIN_MESSAGE_MAP(CTtView, CView)
    //{{AFX_MSG_MAP(CTtView)
    ON_WM_TIMER()
    ON_COMMAND(ID_WHY, OnWhy)
    //}}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()/////////////////////////////////////////////////////////////////////////////
    // CTtView construction/destructionCTtView::CTtView()
    {
    // TODO: add construction code here
    }CTtView::~CTtView()
    {
    }BOOL CTtView::PreCreateWindow(CREATESTRUCT& cs)
    {
    // TODO: Modify the Window class or styles here by modifying
    //  the CREATESTRUCT cs return CView::PreCreateWindow(cs);
    }/////////////////////////////////////////////////////////////////////////////
    // CTtView drawingvoid CTtView::OnDraw(CDC* pDC)
    {
    CTtDoc* pDoc = GetDocument();
    ASSERT_VALID(pDoc);
    // TODO: add draw code for native data here
    pDC->MoveTo(100, 100);
    pDC->LineTo(200,100);
    pDC->MoveTo(200, 100);
    pDC->LineTo(190, 90);
    pDC->MoveTo(200, 100);
    pDC->LineTo(190, 110);
    }/////////////////////////////////////////////////////////////////////////////
    // CTtView printingBOOL CTtView::OnPreparePrinting(CPrintInfo* pInfo)
    {
    // default preparation
    return DoPreparePrinting(pInfo);
    }void CTtView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
    {
    // TODO: add extra initialization before printing
    }void CTtView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
    {
    // TODO: add cleanup after printing
    }/////////////////////////////////////////////////////////////////////////////
    // CTtView diagnostics#ifdef _DEBUG
    void CTtView::AssertValid() const
    {
    CView::AssertValid();
    }void CTtView::Dump(CDumpContext& dc) const
    {
    CView::Dump(dc);
    }CTtDoc* CTtView::GetDocument() // non-debug version is inline
    {
    ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CTtDoc)));
    return (CTtDoc*)m_pDocument;
    }
    #endif //_DEBUG/////////////////////////////////////////////////////////////////////////////
    // CTtView message handlersvoid CTtView::OnTimer(UINT nIDEvent) 
    {
    // TODO: Add your message handler code here and/or call default
    CClientDC dc(this);
    static int x = 10;
    x += 10;
    if(x > 600) 
    x = 0;
    dc.TextOut(0, 10, "                                                                                                                                                                    ");
    dc.TextOut(x, 10, "Test Ok"); CView::OnTimer(nIDEvent);
    }void CTtView::OnWhy() 
    {
    // TODO: Add your command handler code here
    SetTimer(1, 100, NULL);
    }