lesson4_MFC实现单文档应用程序画线
来源:互联网 发布:上海瀚威酩轩 知乎 编辑:程序博客网 时间:2024/06/03 14:36
1>在CDrawView类中增加2个消息响应函数void CDrawView::OnLButtonDown(UINT nFlags, CPoint point) 与void CDrawView::OnLButtonUp(UINT nFlags, CPoint point)
再增加1个成员对象用来保存点CPoint m_ptOrigin;
/////////////////////////////////////////////////////////////////////////////// CDrawView message handlers//鼠标按下时调用如下方法void CDrawView::OnLButtonDown(UINT nFlags, CPoint point) { // TODO: Add your message handler code here and/or call default //MessageBox("view clicked"); m_ptOrigin = point; CView::OnLButtonDown(nFlags, point);}//弹起时调用如下方法void CDrawView::OnLButtonUp(UINT nFlags, CPoint point) { // TODO: Add your message handler code here and/or call default HDC hdc; hdc = ::GetDC(m_hWnd); MoveToEx(hdc,m_ptOrigin.x,m_ptOrigin.y,NULL); LineTo(hdc,point.x,point.y); ::ReleaseDC(m_hWnd,hdc); CView::OnLButtonUp(nFlags, point);}2>按下的方法不变,在弹起的方法中重新实现也可实现划线void CDrawView::OnLButtonUp(UINT nFlags, CPoint point) { // TODO: Add your message handler code here and/or call default CDC *pDC = GetDC(); pDC->MoveTo(m_ptOrigin); pDC->LineTo(point); ReleaseDC(pDC); CView::OnLButtonUp(nFlags,point);}3>按下的方法不变,在弹起的方法中重新实现也可实现划线void CDrawView::OnLButtonUp(UINT nFlags, CPoint point) { // TODO: Add your message handler code here and/or call default CClientDC dc(this); CClientDC dc(GetParent()); dc.MoveTo(m_ptOrigin); dc.LineTo(point);}4>按下的方法不变,在弹起的方法中重新实现也可实现划线void CDrawView::OnLButtonUp(UINT nFlags, CPoint point) { // TODO: Add your message handler code here and/or call default //CWindowDC dc(this); CWindowDC dc(GetParent()); dc.MoveTo(m_ptOrigin); dc.LineTo(point);}
0 0
- lesson4_MFC实现单文档应用程序画线
- 单文档视图应用程序
- 一个单文档应用程序,怎样实现“打开时,弹出一个对话框,而不是单文档”
- MFC单文档两点画线的四种方法
- 单文档应用程序切换视图
- MFC单文档应用程序问题
- 单文档应用程序SDI的视图切换
- 单文档应用程序SDI的视图切换
- OpenGL的单文档应用程序框架
- 修改单文档应用程序框架的大小
- 设置单文档应用程序的背景图片
- 设置单文档应用程序的背景图片
- 基于单文档应用程序背景的修改
- MFC SDI单文档应用程序贴图
- 改变VC++应用程序单文档标题图标
- 单文档应用程序的创建过程
- 设置单文档应用程序的背景图片
- MFC单文档应用程序显示图像
- const 放在函数后表示的意思
- Timus 1327. Fuses
- 运算符一元,二元,三元
- 沙盒路径和本地数据存储方式plist/归档/偏好设置
- mac下常用快捷键
- lesson4_MFC实现单文档应用程序画线
- ZOJ3939 The Lucky Week
- [Java基础] 序列化与反序列化
- Python系列(三)文件的相关操作
- 织梦标签
- 多行文本溢出用省略号表示
- lightoj 1031 - Easy Game 【区间dp】
- Linux用户空间与内核空间
- 多款Android播放器源码集锦(附开发教程)