| 发表于:2007-09-28 11:24:01 楼主 |
感谢各位大虾关心我的问题: 我要实现的功能是:点击鼠标左键后开始显示鼠标路径,抬起后便停止显示 ;在显示路径同时记录鼠标每时刻坐标与position.bin文件中;最后读取bin文件。 现在我的程序中完成了前两个,但是当按下左键开始拖动鼠标时,就报错了。而且是filecore.cpp中的错误,不知道怎么修改。因此现在请教各位资深编程前辈指点一二,小弟不胜感激!!多谢大家了。 主要程序如下: void cmyview::onlbuttondown(uint nflags, cpoint point) { updatedata(true); m_begindraw=false;//判断鼠标是否按下 m_ptorigin=point; //建立存储位置的 position文件 //----------------------------------------------------- route.format( "h:\\route.bin "); file.open( "route ",cfile::modecreate); //------------------------------------------------------- cview::onlbuttondown(nflags, point); } void cmyview::onmousemove(uint nflags, cpoint point) { updatedata(true); //显示坐标 //------------------------------------------------------------ cstring str; str.format( "x=%d,y=%d ",point.x,point.y); ((cmainframe*)getparent())-> m_wndstatusbar.setwindowtext(str); //------------------------------------------------------------- if(m_begindraw){}//如果m_bdraw的值是初始值,即真,则不作图,不记录 else //如果m_bdraw的值已经设为假,则开始画图,记录 { //开始画路径 //-------------------------------------------------------------- cclientdc dc(this); dc.moveto(m_ptorigin); dc.lineto(point); m_ptorigin=point; //-------------------------------------------------------------- //开始记录坐标位置与route.bin文件中 //-------------------------------------------------------------- m_pointmouse.x=point.x; m_pointmouse.y=point.y; if(file.open( "route ",cfile::modewrite)) { file.seektoend(); file.write(&m_pointmouse,sizeof(m_pointmouse)); } //-------------------------------------------------------------- } cview::onmousemove(nflags, point); } void cmyview::onlbuttonup(uint nflags, cpoint point) { m_begindraw=true;//当鼠标键抬起时,m_bdraw又变成假,则停止作图 //按键抬起 //------------------------------------- route.format( "%d ",file.getlength()); file.close(); //------------------------------------- cview::onlbuttonup(nflags, point); } |
|
|
|
|