无效方法有什么作用? [英] What does invalidate method do?

查看:48
本文介绍了无效方法有什么作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

invalidate 方法在 winform 应用程序中做什么?

What does invalidate method do in winform app?

Invalidate() 方法 System.Windows的 control class 中带有六个重载形式..Forms 命名空间.

Invalidate() method comes with six overloaded form inside control class of System.Windows.Forms namespace.

谢谢.....

推荐答案

Windows窗体使用GDI进行呈现.GDI是Windows中的原始图形界面.DirectX是一种较新的接口,最初是为游戏开发而创建的,但现在也已由WPF等更高级别的框架使用.

Windows Forms uses GDI for rendering. GDI is the original graphics interface in Windows. DirectX is a newer interface originally created for games development but now also used by higher level frameworks like WPF.

GDI基于绘画方法的概念.当显示一个窗口时,Windows将向该窗口负责的代码发送一条绘制消息.这将导致绘制方法被调用.然后,paint方法应该将窗口的内容绘制到屏幕上.

GDI is based around the concept of a paint method. When a window is displayed Windows will send a paint message to the code responsible for the window. This will lead to the paint method being called. The paint method should then paint the contents of the window onto the screen.

当GDI程序想要更新显示的内容时,它不能直接将更新的图像绘制到屏幕上.相反,它必须告诉Windows需要更新区域.这称为使无效.然后,Windows将调用相关的绘制方法,以提供有关无效和需要更新的内容的信息.然后绘制方法应将更新的内容绘制到屏幕上.

When a GDI program wants to update what is displayed it cannot directly paint the updated image onto the screen. Instead it has to tell Windows that an area needs to be updated. This is called invalidating a region. Windows will then call the relevant paint method supplying information about what is invalid and needs updating. The paint method should then draw the updated contents to the screen.

当在其他窗口之间拖动窗口时,也会使用这种更新屏幕内容的方法.当开发GDI时,图形硬件相当慢,并且Windows内需要做很多工作来缓存位图并仅使更改无效并进行更新.

This method of updating screen contents is also used when windows are dragged across other windows. When GDI was developed graphics hardware was pretty slow and a lot of work is done inside Windows to cache bitmaps and to only invalidate and update what is changed.

绘制重叠的窗口或子窗口时,它是从前向后完成的,以获取正确的视觉元素分层.这会导致闪烁,在此背景下,先擦除并绘制背景,然后再绘制其他元素.如果重绘速度低于屏幕刷新速度,则可能会出现闪烁现象.这是可能使用Windows窗体创建的GDI应用程序的明显标志.

When overlapping windows or child windows are drawn it is done back to front to get the correct layering of visual elements. This can lead to flicker where a background is erased and drawn followed by other elements in front. If the redraw speed is slower than the screen refresh you might notice some flickering. This is a telltale sign of a GDI application perhaps created using Windows Forms.

在Windows窗体中,当您使无效时,您要求应重绘该控件.

In Windows Forms when you invalidate a control you request that it should be redrawn.

这篇关于无效方法有什么作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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