Any ideas why this does not work?

hog

Well-known member
Joined
Mar 17, 2003
Messages
984
Location
UK
I have a splash form with a photo in a picturebox. I want to draw text on this photo. I have tried using a label with the backcolor set to transparent but it still shows a background colour??

So I have tried this, but the text does not appear?

Code:
 Private Sub frmSplash_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Dim gfxSreen As Graphics = Graphics.FromHwnd(Me.PictureBox1.Handle)

        gfxSreen.DrawString("AnyText", New Font("Comic Sans MS", 20), New SolidBrush(Color.Black), 5, 5)

End Sub

any ideas?
 
You are drawing it in form load, before the form and picture box are shown, and you draw it only once so it will not be there during the next repaint. Do this in the Paint event of your picture box.
 
Nope...still doesnt work :(

Code:
  Private Sub PictureBox1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles PictureBox1.Paint

        Dim gfxSreen As Graphics = Graphics.FromHwnd(Me.PictureBox1.Handle)

        gfxSreen.DrawString("AntyText", New Font("Comic Sans MS", 20), New SolidBrush(Color.Black), 5, 5)

End Sub
 
Dont create your own graphics object, use the "e" argument that passed into the Paint event, it contains the graphics object:
Code:
Private Sub PictureBox1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles PictureBox1.Paint

        e.Graphics.DrawString("AntyText", New Font("Comic Sans MS", 20), New SolidBrush(Color.Black), 5, 5)

End Sub
 
Bugger:)

Id tried this but just used e.drawstring....oh so close:)

Thnx Mutant
 
Back
Top