zoukankan      html  css  js  c++  java
  • MFC画带箭头的直线

    构造一个函数,是在startPoint,endPoint间画一条带箭头的线段:
    void CTry1View::DrawLine(POINT startPoint, POINT endPoint)
    {
    CClientDC dc(this);
    dc.MoveTo(startPoint);
    dc.LineTo(endPoint);
    
    double PI = 3.1415926;
    double t=PI/4; //箭头与直线夹角
    double l=0.2; //箭头边长度占直线长度的百分比
    
    POINT arrowPoint;
    
    arrowPoint.x = (int)(l*((startPoint.x-endPoint.x)*cos(t)-(startPoint.y-endPoint.y)*sin(t))+endPoint.x);
    arrowPoint.y = (int)(l*((startPoint.x-endPoint.x)*sin(t)+(startPoint.y-endPoint.y)*cos(t))+endPoint.y);
    dc.MoveTo(endPoint);
    dc.LineTo(arrowPoint);
    
    arrowPoint.x = (int)(l*((startPoint.x-endPoint.x)*cos(-t)-(startPoint.y-endPoint.y)*sin(-t))+endPoint.x);
    arrowPoint.y = (int)(l*((startPoint.x-endPoint.x)*sin(-t)+(startPoint.y-endPoint.y)*cos(-t))+endPoint.y);
    dc.MoveTo(endPoint);
    dc.LineTo(arrowPoint);
    }

     画用例图的继承关系的带三角箭头的实线:

    #include "stdafx.h"
    #include "LineArrow.h"


    CLineArrow::CLineArrow(void)
    {
    }


    CLineArrow::~CLineArrow(void)
    {
    }


    void CLineArrow::DrawDashedLineArrow(CDC* pDC)
    {
    CPen pen;
    pen.CreatePen(PS_DASH,1,RGB(0,0,0));//笔刷类型,像素宽,笔刷颜色

    }


    void CLineArrow::DrawInheritLine(CDC* pDC)
    {
    double PI = 3.1415926;
    double t = PI / 4;
    double l = 0.2;

    CPoint arrowlftPoint;
    arrowlftPoint.x = (int)(l*((m_start.x-m_end.x)*cos(t)-(m_start.y-m_end.y)*sin(t))+m_end.x);
    arrowlftPoint.y = (int)(l*((m_start.x-m_end.x)*sin(t)+(m_start.y-m_end.y)*cos(t))+m_end.y);

    CPoint arrowRtPoint;
    arrowRtPoint.x = (int)(l*((m_start.x-m_end.x)*cos(-t)-(m_start.y-m_end.y)*sin(-t))+m_end.x);
    arrowRtPoint.y = (int)(l*((m_start.x-m_end.x)*sin(-t)+(m_start.y-m_end.y)*cos(-t))+m_end.y);

    CPoint end;
    end.x = (arrowlftPoint.x + arrowRtPoint.x) / 2;
    end.y = (arrowlftPoint.y + arrowRtPoint.y) / 2;

    pDC->MoveTo(m_start);
    pDC->LineTo(end);

    pDC->MoveTo(m_end);
    pDC->LineTo(arrowlftPoint);


    pDC->MoveTo(m_end);
    pDC->LineTo(arrowRtPoint);

    pDC->MoveTo(arrowlftPoint);
    pDC->LineTo(arrowRtPoint);
    }

     mfc 画线===============http://www.2cto.com/kf/201408/324222.html=============

     字体:http://blog.sina.com.cn/s/blog_6111ce890100rqse.html

    BOOL   CreateFont(    
    
                    int   nHeight,                       //字体的高度
    
                    int   nWidth,                         //字体的宽度
    
                    int   nEscapement,               //字体显示的角度
    
                    int   nOrientation,             //字体的角度
    
                    int   nWeight,                       //字体的磅数
    
                    BYTE   bItalic,                     //斜体字体
    
                    BYTE   bUnderline,               //带下划线的字体
    
                    BYTE   cStrikeOut,               //带删除线的字体
    
                    BYTE   nCharSet,                   //所需的字符集
    
                    BYTE   nOutPrecision,         //输出的精度
    
                    BYTE   nClipPrecision,       //裁减的精度
    
                    BYTE   nQuality,                   //逻辑字体与输出设备的实际
    
                                                                                      //字体之间的精度
    
                   BYTE   nPitchAndFamily,     //字体间距和字体集
    
                   LPCTSTR   lpszFacename       //字体名称
    
                             );  
  • 相关阅读:
    HDU 5585 Numbers
    HDU 3308 LCIS
    POJ 2991 Crane
    POJ 1436 Horizontally Visible Segments
    POJ 3667 Hotel
    HaiHongOJ 1003 God Wang
    【SDOI 2008】 递归数列
    5月19日省中提高组题解
    【HDU 1588】 Gauss Fibonacci
    【POJ 3233】Matrix Power Series
  • 原文地址:https://www.cnblogs.com/Decmber/p/4951871.html
Copyright © 2011-2022 走看看