MFC中的Paint应用 [英] Paint Application in MFC
本文介绍了MFC中的Paint应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在MFC中开发类似于Ms Paint的应用程序,但是我遇到了问题,例如我无法保留绘制的形状,因为在调用了invalidate之后窗口被重新绘制,
请帮助我,因为我是MFC的初学者.
解决方案
请看微软提供的涂鸦示例项目.
当然会发生.您必须记录动作并在WM_PAINT(MFC中的OnPaint)上重画
如果绘画动作很复杂无法记录(如手绘形状,而不是线条,矩形等),您可以绘制到屏幕外的内存DC(MFC中的CDC :: CreateCompatibleDC-想象为位图)并在那里绘制.稍后,您可以使用OnPaint上的CDC-> BitBlt从该DC绘制到屏幕上
我不是MFC向导,我已经习惯了API.我建议您通过msdn获取有关类的更多信息
将点存储在结构中,然后使用这些点在OnPaint中绘制形状.
>
Hi,
I am developing a Ms Paint like application in MFC ,but I am having problem like i am not able to retain the drawn shape,as the window is getting repainted after invalidate is getting called,
Please help me as I am kind a beginner in MFC .
解决方案
Look at the scribble sample project provided by microsoft.
Of course, it happens. You must record actions and re-draw on WM_PAINT (OnPaint in MFC)
If the painting actions are complex & cannot be recorded (like hand drawn shapes instead of lines, rectangles etc) You may draw into an offscreen memory DC (CDC::CreateCompatibleDC in MFC - imagine that as a bitmap) and draw it there. Later you can draw from that DC to screen using CDC->BitBlt on OnPaint
I''m not an MFC wizard, i''m used to the API. I suggest you go thru the msdn for more info on the classes
Store the points in a structure then using the points draw the shapes in OnPaint.
这篇关于MFC中的Paint应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文