画直线(橡皮筋)
来源:互联网 发布:查看linux安装的字体 编辑:程序博客网 时间:2024/04/28 06:51
在《深入浅出MFC》中的step2的程序的基础上进行修改,原程序是连续画线,进行修改使它画直线
void CScribbleView::OnLButtonDown(UINT, CPoint point)
{
// Pressing the mouse button in the view window starts a new stroke
m_pStrokeCur = GetDocument()->NewStroke();
// Add first point to the new stroke
m_pStrokeCur->m_pointArray.Add(point);
SetCapture(); // Capture the mouse until button up.
m_ptPrev = point; // Serves as the MoveTo() anchor point for the
// LineTo() the next point, as the user drags the
// mouse.
m_ptNext = m_ptPrev;
m_button = TRUE;
return;
}
void CScribbleView::OnLButtonUp(UINT, CPoint point)
{
// Mouse button up is interesting in the Scribble application
// only if the user is currently drawing a new stroke by dragging
// the captured mouse.
if (GetCapture() != this)
return; // If this window (view) didn't capture the mouse,
// then the user isn't drawing in this window.
CScribbleDoc* pDoc = GetDocument();
CClientDC dc(this);
CPen* pOldPen = dc.SelectObject(pDoc->GetCurrentPen());
dc.MoveTo(m_ptPrev);
dc.LineTo(point);
dc.SelectObject(pOldPen);
m_pStrokeCur->m_pointArray.Add(point);
ReleaseCapture(); // Release the mouse capture established at
// the beginning of the mouse drag.
m_button =FALSE;
return;
}
void CScribbleView::OnMouseMove(UINT, CPoint point)
{
// Mouse movement is interesting in the Scribble application
// only if the user is currently drawing a new stroke by dragging
// the captured mouse.
//
if(m_button)
{
CClientDC dc(this);
dc.SetROP2(R2_NOT);
//该函数的主要的作用是根据nDrawMode设置的方式重新设定绘图的方式,下面就不同的nDrawMode值具体解释绘图模式是如何改变的
dc.MoveTo(m_ptPrev);
dc.LineTo(m_ptNext);
m_ptNext = point;
dc.MoveTo(m_ptPrev);
dc.LineTo(m_ptNext);
}
return;
}
- 画直线(橡皮筋)
- 画橡皮筋直线
- 橡皮筋技术画直线
- Canvas---Canvas版画图,坐标轴绘制,网格绘制,橡皮筋式画直线
- 2.使用canvas实现简单的画直线橡皮筋式画框
- 【VC6.0】直线的橡皮筋绘图技术
- 橡皮筋类(CRectTracker)
- 橡皮筋类(CRectTracker)
- 橡皮筋类(CRectTracker)
- CRectTracker(橡皮筋)类
- 橡皮筋
- 橡皮筋
- 在MFC中,利用GDI绘制橡皮筋效果-直线,圆,椭圆,矩形
- 橡皮筋技术画折线和矩形
- 2.9.2_橡皮筋辅助画圆
- 简易画图程序(实现橡皮筋功能)
- CRectTracker(橡皮筋类)的应用
- 橡皮筋类(CRectTracker )的使用方法
- 人生成功的生活经典治理名言
- 人生成功的生活经典治理名言
- JavaBean的get、set方法生成器
- 改变鼠标显示样式
- 【C语言小练习】 任意输入N个数,输出其由大到小的数据。
- 画直线(橡皮筋)
- 美到极致是疯狂
- Citrix ICA's basic encryption has been cracked
- php为图片添加水印
- 编写自己的who命令
- wince编程常用控制窗体API
- wince编程常用控制窗体API
- css position: absolute、relative详解
- wince编程常用控制窗体API