Ron,
the Form1 background:
Form1.DefInstance.BackgroundImage = System.Drawing.Image.FromFile(pix)
I would set BackgroundImage in the Load event with the following:
Me.BackgroundImage = System.Drawing.Image.FromFile(pix)
Simply to ensure that all instances of the form have the property set.
and now I can't figure out how to call the Form1_Paint
procedure as the call wants an event as sender ( the e
variable in your code ).
You DO NOT call it as its a form level event, the form itself will call it
when it needs to be called.
VB (.NET, 1, 2, 3, 4, 5, 6) 101. Paint is an event handler for the form
itself, you need to select the Paint event from combo boxes at the top of
the editor to add a handler for the Paint event. Which will add a routine
such as:
Private Sub MainForm_Paint(ByVal sender As Object, ByVal e As
System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
' Kevin's code
End Sub
Alternatively you can override the OnPaint method, as the OnPaint method
raises the Paint event (this should have been explained in the link I gave).
' you can (and should) use the following instead of the above
Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
MyBase.OnPaint(e) ' important this needs to be called!
' Kevin's code
End Sub
OnPaintBackground is only an overriden method.
Protected Overrides Sub OnPaintBackground(ByVal e As PaintEventArgs)
If Me.BackgroundImage Is Nothing Then Exit Sub
e.Graphics.DrawImage(Me.BackgroundImage, Me.ClientRectangle)
End Sub
The paint event (Paint or OnPaint) & OnPaintBackground are automatically
called by the form itself when the form needs to be painted (when you or
windows calls Form.Update either directly or indirectly). This should also
have been explained in the link I gave.
You should only use Paint event or OnPaintBackground routine, not both.
Again the link I gave should explain when to use on or the other.
Hope this helps
Jay