CreateGraphics和Paint事件的Graphics对象有什么区别? [英] What is the difference between CreateGraphics and a Paint event's Graphics object?
问题描述
有人可以解释作为 pevent.Graphics
传递的图形
对象与通过调用返回 this.CreateGraphics()
?
每当一个 Paint
事件被引发,给你一个 Graphics
对象来绘制。这是作为 pevent.Graphics
传递的。绘制到这个 Graphics
对象中就是绘制元素的方式。
您可能想要使用 您不会 使用 Can someone explain the difference between the Whenever a The only time you might want to use You will never use 这篇关于CreateGraphics和Paint事件的Graphics对象有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋! CreateGraphics $基本上不应该使用c $ c>。它从窗口句柄中即时创建一个新的
Graphics
对象。您可以绘制它返回的 Graphics
对象,但是当您下一次绘制 Paint >
CreateGraphics
的唯一时间是用于特殊效果,如显示真实拖动过程中的时间反馈。您希望在下一次元素重新绘制时被删除,所以您继续并使用 CreateGraphics
来获取临时画布以绘制到而拖动事件正在进行中。
CreateGraphics
一个 Paint
事件处理程序方法。没有意义 - 你得到一个 Graphics
对象来绘制已经!Graphics
object that is passed as pevent.Graphics
and the one that is returned by a call to this.CreateGraphics()
?Paint
event is raised, you are given a Graphics
object to draw into. This is passed as pevent.Graphics
. Drawing into this Graphics
object is how you paint the element.CreateGraphics
should basically never be used. It creates a new Graphics
object on-the-fly from a window handle. You can draw into the Graphics
object it returns, but anything you draw into it will be obliterated the next time that a Paint
event is raised.CreateGraphics
is for special effects, like showing real-time feedback during a drag. You want that to be erased the next time that the element is repainted, so you go ahead and use CreateGraphics
to get a temporary canvas to draw onto while the drag event is in progress.CreateGraphics
inside of a Paint
event handler method. There is no point—you are given a Graphics
object to draw into already!