Me.InvokePaint争论,适用于Windows窗体 [英] Me.InvokePaint arguements, for windows form

查看:141
本文介绍了Me.InvokePaint争论,适用于Windows窗体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序中,我需要绘制表单,但仅在单击按钮之后.因此,我在me.paint事件中有一个布尔值和一个if语句.

In my application, i need to paint my form, but only after a button click. So, i have a boolean and an if statement in the me.paint event.

我不想每次都使用me.refresh,因为它最终会对速度产生重大影响.

I do not want to use me.refresh each time, because it eventually has a major impact on the speed.

我应该在Me.InvokePaint的参数中放置什么?

此命令位于Form1的Button1.click下.

This command is under Button1.click, for form1.

参数为(c为system.windows.forms.control,e为system.windows.painteventargs)

The arguments are (c as system.windows.forms.control, e as system.windows.painteventargs)

但是调用此函数时我要插入什么?

But what do i insert when i call this function?

推荐答案

为什么不只使用 Control.Invalidate方法 有一些重载,可让您控制要重绘的内容.您可以使整个表格无效,但不能使其子控件无效 OR ,您可以在一些重载中传递一个Rectangle,以指示要重绘的表单的矩形区域.您也可以只调用不带任何参数的Invalidate,这将使整个表单及其子控件无效.

 Why not just use the Control.Invalidate Method.  The Control.Invalidate Method has a few overloads that allow you to control what is repainted.  You can invalidate the whole Form but, not its child controls OR you can pass a Rectangle in some of the overloads which indicates the rectangle area of the form you want repainted.  You can also just call Invalidate without any parameters which will invalidate the whole form and its child controls.

  Refresh方法可能影响速度的原因是因为它会立即向窗体或控件发送一个绘制消息,将其放置在任何其他消息之前,这将导致它在调用Refresh方法时重新绘制窗体或控件. . 处理完绘制消息后,它将继续处理其他消息和下一行代码.

 The reason the Refresh method may effect the speed is because it will immediately send a paint message to the form or control placing it ahead of any other messages which will cause it to repaint the form or control upon calling the Refresh method.  After processing the paint message, it will continue processing other messages and the next line of code.

Invalidate方法将通知表单或控件需要重新绘制,但是,除非完成处理任何其他消息的表单或控件并且有时间重绘,否则该表单或控件将不会重新绘制.那意味着 如果快速重复调用Invalidate方法,它可能会跳过一些绘画消息,从而导致动画或运动看起来跳动.

 The Invalidate method will notify the form or control that it needs to be repainted but,  the form or control will not be repainted until the form or control is done processing any other messages and it has time to repaint.  That means that if the Invalidate method is being called repeatedly at a fast pace,  it may skip some of the paint messages causing animation or movement to look jumpy.


这篇关于Me.InvokePaint争论,适用于Windows窗体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆