Problem with my approach is that image, text or line drawn, lags by maybe 0.2 seconds, when resizing the form. So if you need an image in bottom right corner, it takes that 0.2 seconds to come in place after resize. Also, if you do heavy resizing, it starts lagging down to 1-2FPS, while the form expands on a big screen. Sample code looks like this (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
Is there anything that can be done to make it smoother?
Resizing your window is always going to involve redrawing the image in the new location. However, there are some things you can try that may or may not make the redrawing more efficient.