求助:
afx_msg void OnLButtonDown(UINT,CPoint point)
{
SetCapture();
LogicalCoor(&point);
shape->sPoint=shape->ePoint=point;
}
afx_msg void OnMouseMove(UINT,CPoint point)
{
if(this==GetCapture())
{
CClientDC dc(this);
dc.SetROP2(R2_NOT); OnPrepareDC(&dc);
LogicalCoor(&point); shape->draw(dc,width,lcolor,fcolor);
shape->ePoint=point;
shape->draw(dc,width,lcolor,fcolor);
}
} afx_msg void OnLButtonUp(UINT,CPoint point)
{
if(this==GetCapture())
{
LogicalCoor(&point);
CClientDC dc(this);
shape->ePoint=point;
//shape->draw(dc,width,lcolor,fcolor); MyDocument *doc=(MyDocument *)GetDocument();
GraphicObject obj(shape->GetShapeNum(),width,lcolor,fcolor,shape->sPoint,shape->ePoint);
doc->AddObject(obj); PhysicalCoor(&shape->sPoint);
PhysicalCoor(&shape->ePoint);
CRect rect(shape->sPoint,shape->ePoint);
rect.NormalizeRect();
rect.InflateRect(5,5);
InvalidateRect(&rect);
ReleaseCapture();
}
}
说明:这是一个带有滚动条的简单绘图程序。GraphicObject是保存形状对象的类。
问题:1.这是一个包含滚动条的窗口,它要进行逻辑坐标和物理坐标的转换,其中主要集中在OnLButtonDown,OnMouseMove,OnLButtonUp这3个函数中。请问什么时候需要进行坐标的转换。2.在OnLButtonUp这个函数中OnPrepareDC(&dc);LogicalCoor(&point);为什么连着写了这2个,意思是什么。3.在OnMouseMove函数中使用了dc.SetROP2(R2_NOT); //设置绘图模式
shape->draw(dc,width,lcolor,fcolor);//画出形状对象
shape->ePoint=point;
shape->draw(dc,width,lcolor,fcolor);//再画出形状对象
为什么在OnLButtonUp中,将其注释掉了//shape->draw(dc,width,lcolor,fcolor);
这里是如何确定最终的图形的。我不能理解,因为它的绘图模式是R2_NOT,是绘图动作与屏幕的底色相反。在mousemove中连画了2次就造成图形被清除的效果,为什么在lbuttonup中却注释掉那个画图的动作。
afx_msg void OnLButtonDown(UINT,CPoint point)
{
SetCapture();
LogicalCoor(&point);
shape->sPoint=shape->ePoint=point;
}
afx_msg void OnMouseMove(UINT,CPoint point)
{
if(this==GetCapture())
{
CClientDC dc(this);
dc.SetROP2(R2_NOT); OnPrepareDC(&dc);
LogicalCoor(&point); shape->draw(dc,width,lcolor,fcolor);
shape->ePoint=point;
shape->draw(dc,width,lcolor,fcolor);
}
} afx_msg void OnLButtonUp(UINT,CPoint point)
{
if(this==GetCapture())
{
LogicalCoor(&point);
CClientDC dc(this);
shape->ePoint=point;
//shape->draw(dc,width,lcolor,fcolor); MyDocument *doc=(MyDocument *)GetDocument();
GraphicObject obj(shape->GetShapeNum(),width,lcolor,fcolor,shape->sPoint,shape->ePoint);
doc->AddObject(obj); PhysicalCoor(&shape->sPoint);
PhysicalCoor(&shape->ePoint);
CRect rect(shape->sPoint,shape->ePoint);
rect.NormalizeRect();
rect.InflateRect(5,5);
InvalidateRect(&rect);
ReleaseCapture();
}
}
说明:这是一个带有滚动条的简单绘图程序。GraphicObject是保存形状对象的类。
问题:1.这是一个包含滚动条的窗口,它要进行逻辑坐标和物理坐标的转换,其中主要集中在OnLButtonDown,OnMouseMove,OnLButtonUp这3个函数中。请问什么时候需要进行坐标的转换。2.在OnLButtonUp这个函数中OnPrepareDC(&dc);LogicalCoor(&point);为什么连着写了这2个,意思是什么。3.在OnMouseMove函数中使用了dc.SetROP2(R2_NOT); //设置绘图模式
shape->draw(dc,width,lcolor,fcolor);//画出形状对象
shape->ePoint=point;
shape->draw(dc,width,lcolor,fcolor);//再画出形状对象
为什么在OnLButtonUp中,将其注释掉了//shape->draw(dc,width,lcolor,fcolor);
这里是如何确定最终的图形的。我不能理解,因为它的绘图模式是R2_NOT,是绘图动作与屏幕的底色相反。在mousemove中连画了2次就造成图形被清除的效果,为什么在lbuttonup中却注释掉那个画图的动作。
解决方案 »
- 顺便问下大家,开发基于SNMP的网管程序,用Snmp.h提供的SNMP API好还是Winsnmp.h提供的WinSNMP API好,为什么,谢谢
- Standard C&C++群,欢迎你的加入
- 请问:关于rtp打包大小的问题?
- 哪儿有VC++ 6.0企业版的购买啊?还有企业版和标准版有什么区别呢??
- 申请图象版主
- 请教大虾有关VC通过ADO的COMMAND对象调用存储过程时参数创建问题!!
- 本机架设smtp服务器发送大量邮件
- 谁要网络管理软件(很牛b的)
- 帮我看看这段程序,为什么列表框没有标题头
- 100分人人有,MCSD,MCSE拿多少工资啊?有没有意义啊? 在先等待..
- sendbuf里的buf有大小限制吗
- 怎么添加静态背景
并且,偶数次才是擦除!