#0143 CClientDC dc(this);
#0144 OnPrepareDC(&dc);
#0145 dc。DPtoLP(&point);
#0146
#0147 m_pStrokeCur = GetDocument()…》NewStroke();
#0148 // Add first point to the new stroke
#0149 m_pStrokeCur…》m_pointArray。Add(point);
#0150
#0151 SetCapture(); // Capture the mouse until button up。
#0152 m_ptPrev = point; // Serves as the MoveTo() anchor point for the
#0153 // LineTo() the next point; as the user drags the
#0154 // mouse。
#0155
#0156 return;
#0157 }
#0158
#0159 void CScribbleView::OnLButtonUp(UINT; CPoint point)
#0160 {
#0161 // Mouse button up is interesting in the Scribble application
#0162 // only if the user is currently drawing a new stroke by dragging
#0163 // the captured mouse。
#0164
#0165 if (GetCapture() != this)
#0166 return; // If this window (view) didn"t capture the mouse;
#0167 // then the user isn"t drawing in this window。
897
…………………………………………………………Page 960……………………………………………………………
第五篇 附錄
#0168
#0169 CScribbleDoc* pDoc = GetDocument();
#0170
#0171 CClientDC dc(this);
#0172
#0173 // CScrollView changes the viewport origin and mapping mode。
#0174 // It"s necessary to convert the point from device coordinates
#0175 // to logical coordinates; such as are stored in the document。
#0176 OnPrepareDC(&dc); // set up mapping mode and viewport origin
#0177 dc。DPtoLP(&point);
#0178
#0179 CPen* pOldPen = dc。SelectObject(pDoc…》GetCurrentPen());
#0180 dc。MoveTo(m_ptPrev);
#0181 dc。LineTo(point);
#0182 dc。SelectObject(pOldPen);
#0183 m_pStrokeCur…》m_pointArray。Add(point);
#0184
#0185 // Tell the stroke item that we"re done adding points to it。
#0186 // This is so it can finish puting its bounding rectangle。
#0187 m_pStrokeCur…》FinishStroke();
#0188
#0189 // Tell the other views that this stroke has been added
#0190 // so that they can invalidate this stroke"s area in their
#0191 // client area。
#0192 pDoc…》UpdateAllViews(this; 0L; m_pStrokeCur);
#0193
#0194 ReleaseCapture(); // Release the mouse capture established at
#0195 // the beginning of the mouse drag。
#0196 return;
#0197 }
#0198
#0199 void CScribbleView::OnMouseMove(UINT; CPoint point)
#0200 {
#0201 // Mouse movement is interesting in the Scribble application
#0202 // only if the user is currently drawing a new stroke by dragging
#0203 // the captured mouse。
#0204
#0205 if (GetCapture() != this)
#0206 return; // If this window (view) didn"t capture the mouse;
#0207 // then the user isn"t drawing in this window。
#0208
#0209 CClientDC dc(this);
#0210 // CScrollView changes the viewport origin and mapping mode。
#0211 // It"s necessary to convert the point from device coordinates
#0212 // to logical coordinates; such as are stored in the document。
#0213 OnPrepareDC(&dc);
898
…………………………………………………………Page 961……………………………………………………………
附錄B Scribble Step5 完整原始碼
#0214 dc。DPtoLP(&point);
#0215
#0216 m_pStrokeCur…》m_pointArray。Add(point);
#0217
#0218 // Draw a line from the previous detected point in the mouse
#0219 // drag to the current point。
#0220 CPen* pOldPen = dc。SelectObject(GetDocument()…》GetCurrentPen());
#0221 dc。MoveTo(m_ptPrev);
#0222 dc。LineTo(point);
#0223 dc。SelectObject(pOldPen);
#0224 m_ptPrev = point;
#0225 return;
#0226 }
#0227
#0228 void CScribbleView::OnUpdate(CView* /* pSender */; LPARAM /* lHint */;
#0229 CObject* pHint)
#0230 {
#0231 // The document has informed this view that some data has changed。
#0232
#0233 if (pHint != NULL)
#0234 {
#0235 if (pHint…》IsKindOf(RUNTIME_CLASS(CStroke)))
#0236 {
#0237 // The hint is that a stroke as been added (or changed)。
#0238 // So; invalidate its rectangle。
#0239 CStroke* pStroke = (CStroke*)pHint;
#0240 CClientDC dc(this);
#0241 OnPrepareDC(&dc);
#0242 CRect rectInvalid = pStroke…》GetBoundingRect();
#0243 dc。LPtoDP(&rectInvalid);
#0244 InvalidateRect(&rectInvalid);
#0245 return;
#0
小说推荐
- Java编程思想第4版[中文版](PDF格式)
- -Page 1-Page 2《Thinking In Java》中文版作者:Bruce Eckel主页:http/BruceEckel.编译:Trans Bot主页:http/memberease~transbot致谢-献给那些直到现在仍在孜孜不倦创造下一代计算机语言的人们!指导您利用万维网的语言进
- 最新章:第295章
- VB2008从入门到精通(PDF格式英文版)
- -Page 1(R)The eXperT’s Voice inBeginningVB 2008From Novice to ProfessionalChristian Gross-Page 2-Page 3-Beginning VB 2008From Novice to Professional■C
- 最新章:第214章
- oracle从入门到精通(PDF格式)
- -Page 1-Oracle 从入门到精通-Page 2-资源来自网络,仅供学习 Oracle 从入门到精通一、SQL 8
- 最新章:第37章
- C语言游戏编程从入门到精通(PDF格式)
- -Page 1-Page 2-Page 3-Page 4-Page 5-Page 6-Page 7-Page 8-Page 9-Page 10-Page 11-Page 12-Page 13-Page 14
- 最新章:第4章
- 深入浅出
- 《深入浅出》作者:白小骨晋江VIP20140610完结+1番外非V章节总点击数:67370 总书评数:209 当前被收藏数:764 文章积分:11,386,657文案:每个前男友都是女人掉过的坑,从何典阳这个坑里往外爬的梁温暖一脸血表示,何典阳他这个深坑实在太坑爹。何典阳:我是坑?梁温暖…别看我,我
- 最新章:第74章
- 深入浅出[娱乐圈]
- 文案【忠犬影帝攻X傲娇明星受,1V1轻松甜文,前期互相试探,38章在一起后甜甜甜,两人都有细微的变化和成长~这也是我用心构思攻受感情发展的文,但数据有点太惨了,没入V可以全文免费看,还是想求点收藏呀,数据好看点吧,让我开心一下(笑哭.jpg)流量偶像白漾和影帝顾瑜祁关系很僵,传言两人出道时不合而互相
- 最新章:第59章
- JMS简明教程(PDF格式)
- -Page 1-JMS1.1规范中文版卫建军2007‐11‐22-Page 2
- 最新章:第28章
- SQL语言艺术(PDF格式)
- -Page 1-SQLSSQQLL语言艺术内容介绍本书分为12章,每一章包含许多原则或准则,并通过举例的方式对原则进行解释说明。这些例子大多来自于实际案例,对九种SQL经典查询场景以及其性能影响讨论,非常便于实践,为你数据库应用维护人员阅读。资深 SQL 专家 Stéphane Faroult倾力打
- 最新章:第27章
- C语言实例教程(PDF格式)
- -Page 1-前 言Visual C+是开发运行于Windows 95和Windows NT环境下的Win32应用程序的可视化编程工具中最重要的成员之一,它为软件开发人员提供了完整的编辑、编译和调试工具和建立于Win32 API(ApplicationProgramming Interface)基
- 最新章:第143章