怎样使用MFC单文档程序编写一个鼠标画线程序?

[复制链接]
查看11 | 回复2 | 2011-9-19 01:17:37 | 显示全部楼层 |阅读模式
回复

使用道具 举报

千问 | 2011-9-19 01:17:37 | 显示全部楼层
不难,留邮箱,我发给你。随便加点分啊
回复

使用道具 举报

千问 | 2011-9-19 01:17:37 | 显示全部楼层
在visualC6.0里面文件-新建-工程里面的MFCAppwizard[EXE]除了第二步选单文档,基本上都是默认的。建一个文件进行一下操作我建的文件名为ZuoBiao在CZuoBiaoView.h里面添加变量:intm;CPointp1,p2;在构造函数里面初使化m。CZuoBiaoView::CZuoBiaoView(){//TODO:addconstructioncodeherem=0;}在资源文件Menu中的IDR_MAINFRAME中添加消息句柄OnLButtonDown,OnLButtonUp,OnMouseMove.再回到ZuoBiaoView.cpp中编译一下程序voidCZuoBiaoView::OnLButtonDown(UINTnFlags,CPointpoint){//TODO:Addyourmessagehandlercodehereand/orcalldefaultCClientDCdc(this);m=1;p1=point;CView::OnLButtonDown(nFlags,point);}voidCZuoBiaoView::OnLButtonUp(UINTnFlags,CPointpoint){//TODO:Addyourmessagehandlercodehereand/orcalldefaultp2=point;CClientDCdc(this);OnPrepareDC(dc.MoveTo(p1);dc.LineTo(p2);m=0;CView::OnLButtonUp(nFlags,point);}voidCZuoBiaoView::OnMouseMove(UINTnFlags,CPointpoint){//TODO:Addyourmessagehandlercodehereand/orcalldefaultstaticintn=0;switch(n){case1:p2=point;break;case2:p1=p2;p2=point;n=0;break;}CClientDCdc(this);OnPrepareDC(if(m==1){dc.MoveTo(p1);dc.LineTo(p2);}CView::OnMouseMove(nFlags,point);}
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行