如何清除cclientdc完成的图纸? [英] How can I clear drawings done by cclientdc?
本文介绍了如何清除cclientdc完成的图纸?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
i我在MFC vc ++上用拨号做图纸。
i我根据我得到的不同输入绘制线条从序列号。
现在我想在我得到另一个输入时清除图纸。
< b>我尝试了什么:
Hello people,
i am doing drawings on dialof in MFC vc++.
i am drawing lines as per the different inputs i am getting from the serial.
now i want to clear the drawings when i get another input.
What I have tried:
CClientDC dc(GetDlgItem(IDC_STATICDISPLAY));
CPen lDot(PS_DASH, 2, RGB(255, 255, 255));
dc.SelectObject(&lDot);
dc.Rectangle(a,b,c,d);
这里a,b,c,d是我的不同输入,我从串口通信。
每个输入我想要清除旧图纸并用新数据绘制新行。
和
Here a,b,c,d are my different inputs which i am getting from the serial communication.
at each input i want to clear the older drawings and draw a new lines with new data.
And
GetDlgItem(IDC_STATICDISPLAY)
是我在对话框中绘制线条的组框。
is the group box in which i am drawing lines in dialog.
推荐答案
GetDlgItem(IDC_STATICDISPLAY) - > ;无效(true);
这将导致组框被删除并重新绘制。擦除意味着将为控件绘制默认背景。
GetDlgItem(IDC_STATICDISPLAY)->Invalidate( true );
That will cause the group box to be erased and redrawn. Erased means the default background will be drawn for the control.
如果控件是完全所有者绘制的,您应该在第一次绘制调用时使用带有bckground颜色的FillRect。
我建议您将控件的Windows控件和其他常量对象(如笔)存储为成员变量,以提高性能。
If the control is completly owner drawn that you should use FillRect with your bckground color at first draw call.
And I would suggest that you store the Windows-handle of the control and other constant objects (like the pen) as member variables to improve performance.
这篇关于如何清除cclientdc完成的图纸?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文