我的方法的问题是,在调整表单大小时,图像、文本或绘制的线条可能会滞后 0.2 秒。因此,如果您需要右下角的图像,则在调整大小后需要 0.2 秒才能到位。此外,如果您进行大量调整大小,它开始滞后到 1-2FPS,而表单在大屏幕上展开。示例代码如下所示(VB.NET):
Public Class Form1
Protected Overrides Sub OnPaint(e As System.Windows.Forms.PaintEventArgs)
MyBase.OnPaint(e)
Dim icon As Icon = SystemIcons.Exclamation
Dim imageWidth As Integer = icon.Width
Dim imageHeight As Integer = icon.Height
e.Graphics.DrawIcon(icon, Me.ClientRectangle.Right - imageWidth,
Me.ClientRectangle.Bottom - imageHeight)
End Sub
Private Sub Form1_Resize(sender As Object, e As System.EventArgs) Handles Me.Resize
Me.Invalidate()
End Sub
End Class
有什么办法可以让它更顺畅吗?