***怎样让移动图像显示更快一些***
Hide Controls When Setting Properties to Avoid Multiple Repaints
Every repaint is expensive. The fewer repaints Visual Basic must perform, the faster your application will appear. One way to reduce the number of repaints is to make controls invisible while you are manipulating them. For example, suppose you want to resize several list boxes in the Resize event for the form:
Sub Form_Resize ()
Dim i As Integer, sHeight As Integer
sHeight = ScaleHeight / 4
For i = 0 To 3
lstDisplay(i).Move 0, i * sHeight, _
ScaleWidth, sHeight
Next
End Sub
This creates four separate repaints, one for each list box. You can reduce the number of repaints by placing all the list boxes within a picture box, and hiding the picture box before you move and size the list boxes. Then, when you make the picture box visible again, all of
the list boxes are painted in a single pass:
在vb中用move方法移动图片时,速度有些慢,当图片很大时,这时可以用下面的方法:
Sub Form_Resize ()
Dim i As Integer, sHeight As Integer
picContainer.Visible = False
picContainer.Move 0, 0, ScaleWidth, ScaleHeight
sHeight = ScaleHeight / 4
For i = 0 To 3
lstDisplay(i).Move 0, i * sHeight, _
ScaleWidth, sHeight
Next
picContainer.Visible = True
End Sub
Note that this example uses the Move method instead of setting the Top and Left properties. The Move method sets both properties in a single operation, saving additional repaints.
博客介绍了让移动图像显示更快的方法,即设置属性时隐藏控件以避免多次重绘。因为每次重绘成本高,减少重绘次数可提升应用速度。如在调整多个列表框大小时,可将其置于图片框内,操作前隐藏图片框,操作后再显示,还可使用Move方法减少重绘。
6472

被折叠的 条评论
为什么被折叠?



