资源简介
c++ code for drawing arrows in any CDC

代码片段和文件信息
#include “Arrow.h“
#include
// ArrowTo()
//
void ArrowTo(HDC hDC int x int y ARROWSTRUCT *pA) {
POINT ptTo = {x y};
ArrowTo(hDC &ptTo pA);
}
// ArrowTo()
//
void ArrowTo(HDC hDC const POINT *lpTo ARROWSTRUCT *pA) {
POINT pFrom;
POINT pbase;
POINT aptPoly[3];
float vecLine[2];
float vecLeft[2];
float fLength;
float th;
float ta;
// get from point
MoveToEx(hDC 0 0 &pFrom);
// set to point
aptPoly[0].x = lpTo->x;
aptPoly[0].y = lpTo->y;
// build the line vector
vecLine[0] = (float) aptPoly[0].x - pFrom.x;
vecLine[1] = (float) aptPoly[0].y - pFrom.y;
// build the arrow base vector - normal to the line
vecLeft[0] = -vecLine[1];
vecLeft[1] = vecLine[0];
// setup length parameters
fLength = (float) sqrt(vecLine[0] * vecLine[0] + vecLine[1] * vecLine[1]);
th = pA->nWidth / (2.0f * fLength);
ta = pA->nWidth / (2.0f * (tanf(pA->fTheta) / 2.0f) * fLength);
// find the base of the arrow
pbase.x = (int) (aptPoly[0].x + -ta * vecLine[0]);
pbase.y = (int) (aptPoly[0].y + -ta * vecLine[1]);
// build the points on the sides of the arrow
aptPoly[1].x = (int) (pbase.x + th * vecLeft[0]);
aptPoly[1].y = (int) (pbase.y + th * vecLeft[1]);
aptPoly[2].x = (int) (pbase.x + -th * vecLeft[0]);
aptPoly[2].y = (int) (pbase.y + -th * vecLeft[1]);
MoveToEx(hDC pFrom.x pFrom.y NULL);
// draw we‘re fillin‘...
if(pA->bFill) {
LineTo(hDC aptPoly[0].x aptPoly[0].y);
Polygon(hDC aptPoly 3);
}
// ... or even jes chillin‘...
else {
LineTo(hDC pbase.x pbase.y);
LineTo(hDC aptPoly[1].x aptPoly[1].y);
LineTo(hDC aptPoly[0].x aptPoly[0].y);
LineTo(hDC aptPoly[2].x aptPoly[2].y);
LineTo(hDC pbase.x pbase.y);
MoveToEx(hDC aptPoly[0].x aptPoly[0].y NULL);
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 1831 2002-12-01 14:29 Arrow.cpp
文件 743 2002-12-01 14:28 Arrow.h
文件 3726 2002-12-01 12:59 ArrowTest.cpp
文件 4664 2002-12-01 14:26 ArrowTest.dsp
文件 541 2002-12-01 12:59 ArrowTest.dsw
文件 1400 2002-12-01 12:59 ArrowTest.h
文件 8739 2002-12-01 12:59 ArrowTest.rc
文件 1721 2002-12-01 14:29 ChildView.cpp
文件 1267 2002-12-01 12:59 ChildView.h
文件 3286 2002-12-01 12:59 MainFrm.cpp
文件 1744 2002-12-01 12:59 MainFrm.h
目录 0 2002-12-01 12:59 res\
文件 1078 2002-12-01 12:59 res\ArrowTest.ico
文件 401 2002-12-01 12:59 res\ArrowTest.rc2
文件 718 2002-12-01 12:59 res\Toolbar.bmp
文件 497 2002-12-01 12:59 Resource.h
文件 211 2002-12-01 12:59 StdAfx.cpp
文件 1054 2002-12-01 12:59 StdAfx.h
- 上一篇:Kinect2.0+PCL实现点云显示
- 下一篇:地球仪纹理型纹理贴图 C++代码
相关资源
- 国际象棋的qt源代码
- C++中头文件与源文件的作用详解
- C++多线程网络编程Socket
- VC++ 多线程文件读写操作
- 利用C++哈希表的方法实现电话号码查
- 移木块游戏,可以自编自玩,vc6.0编写
- C++纯文字DOS超小RPG游戏
- VC++MFC小游戏实例教程(实例)+MFC类库
- 连铸温度场计算程序(C++)
- 6自由度机器人运动学正反解C++程序
- Em算法(使用C++编写)
- libstdc++-4.4.7-4.el6.i686.rpm
- VC++实现CMD命令执行与获得返回信息
- 白话C++(全)
- C++标准库第1、2
- 大数类c++大数类
- C++语言编写串口调试助手
- c++素数筛选法
- C++ mqtt 用法
- 商品库存管理系统 C++ MFC
- c++ 多功能计算器
- C++17 In Detail
- usb之CDC(CDC_Standalone.rar)
- 嵌入式QtC++编程课件
- 颜色识别形状识别STM103嵌入式代码
- c++ 邮件多附件群发
- c++ 透明代理(hookproxy)
- mfc 调用redis
- FTP客户端源码(c++)
- c++ 画图(14Qt-XPS)
评论
共有 条评论