Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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?

 


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?

My website
  • *Experts*
Posted
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.
Posted

Nope...still doesn't work :(

 


 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

My website
  • *Experts*
Posted

Dont create your own graphics object, use the "e" argument that passed into the Paint event, it contains the graphics object:

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...