可以画点并拖动点,画点与点之间的直线并可以鼠标拖动直线变形。用于画平面图(图:指数据结构中的图结构)。
解决方案 »
- [Help]求VLC media player的源代码。。。
- 『兔子党』终于2颗星了,能散300分了
- 请问通过数据库保存数据和通过写流文件保存数据在读写时那个快?
- 属性函数与操作函数的区别是什么?
- 新手问题(对话框中,如何显示GIF文件?)望详细告知!
- 如何想把状态栏放大,里边的字也随之放大!
- 解决后立即给分!我在使用CTabCtrl 控件时为什么用GetItem(sel, &item)得不到当前的标题,并且返回值始终为FALSE?
- 求一个 bindiocompletion 线程池实现的套接字通信例子
- 2 error(s), 0 warning(s)请问如何处理????? LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main Debug/aa
- 映射问题
- 树控件自绘wm_paint消息//只出现GradientFillRect函数效果、树节点的字都没有!
- union中的数据是不是只有一个是有意义的?
BOOL IsPress;//为真时是按下,为假时松下
在鼠标左键按下时设真,在鼠标左键松开时设为假,这样,在鼠标移动函数里就根据IsPress的值来决定是否画线,是否移动
这是一个 直线点击 测试的 问题。
vc6 帮助中 有 一个 “W32HIT”的例子。
点 显示主题。
在 前面 有 例子 下载 链接。
画了点和直线 ,但是直线怎么用鼠标拖动变成曲线呢??类似windows画图中,原来是直线,用鼠标拖成曲线
//
BOOL CTtfShowDlg::QuadraticBezier(CDC *pDC,const POINT* lpPoints, int nCount)
{
double t;
double dt=(double)1/POINTS_ON_CURVE;
CPoint pt;
int i;
//afxDump << nCount << "=nCount\n";
for(i=0 ; i < nCount - 2 ; i += 2)
{
if(i==0)
{// only 1 start point need to be set !
pDC->MoveTo(lpPoints[0]);
}
for(t=0.0 ;t < 1.0 + dt ;t += dt)
{// 3 points each,cubic Bezier curve.
pt.x=(long)((1-t)*(1-t)*lpPoints[0+i].x +
2*t*(1-t)*lpPoints[1+i].x +
t*t*lpPoints[2+i].x );
pt.y=(long)((1-t)*(1-t)*lpPoints[0+i].y +
2*t*(1-t)*lpPoints[1+i].y +
t*t*lpPoints[2+i].y );
pDC->LineTo(pt);
// pDC->SetPixel(pt,0xFF0000);// blue !
}
}
//
return TRUE;
}
把直线2端点 和 鼠标点击点 做成 CPoint pt[3];、、 鼠标点在 pt[1]
调用:
QuadraticBezier(pDC, pt, 3);
鼠标点 不 在曲线上 !
不好意思,好久没上CSDN了,我试一试哈
(OnLButtonDown)把直线2端点 和 鼠标点击点 做成 CPoint pt[3];、、 鼠标点在 pt[1]
至于“判断鼠标是否移动到了直线或曲线”还是 找 ‘W32HIT’ 例子。
Last reviewed: September 29, 1995
Article ID: Q121960
//
Win32: Hit Testing Lines and Curves
Dennis Crain
Microsoft Developer Network Technology GroupCreated: February 8, 1994Click to open or copy the files in the W32HIT sample application for this technical article.Abstract
Useful graphics applications, such as CAD or drawing programs, permit the user to select and manipulate graphics objects. This article describes three methods for detecting if the user has selected a line or a curve.The first method is used to hit test lines. It uses two-dimensional vector techniques that resolve the vector components of the line and the point at which the user clicked the mouse. These vector methods are described in detail in the "Use of Two-Dimensional Vectors with Windows NT" technical article in the Microsoft® Development Library.
...
“直线或曲线的点击测试.rar”0 分
http://download.csdn.net/detail/schlafenhamster/4914656
请参考。
BOOL PolyBezier(
HDC hdc, // handle to device context
CONST POINT *lppt, // pointer to endpoints and control points
DWORD cPoints // count of endpoints and control points
);鼠标移动改变某个POINT的值,然后重画