Public Class Form2 Private imageDeFond As New Bitmap("image01.jpg") 'L'image doit se trouver pour l'exemple dans le dossier de l'exécutable 'mais on pourrait aussi la mettre en ressources Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load ' End Sub Private Sub Form2_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint Dim maFonte As New Font("Microsoft Sans Serif", 12, FontStyle.Bold) 'Dessiner l'image e.Graphics.DrawImage(imageDeFond, 0, 0, imageDeFond.Width, imageDeFond.Height) 'Dessiner le texte "Coucou", avec maFonte, en noir, à la position (10,100) e.Graphics.DrawString("Coucou", maFonte, Brushes.Black, 10, 100) End Sub End Class
Private Sub Form1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles Me.KeyPress Dim g As Graphics = PictureBox1.CreateGraphics g.DrawString(e.KeyChar, Me.Font, Brushes.Black, 1, 1) g.DrawString(e.KeyChar, Me.Font, Brushes.White, 2, 2) End Sub
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionPrivate Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim g As Graphics = PictureBox8.CreateGraphics g.DrawString("sssssssssssssss", Me.Font, Brushes.Black, 2, 2) End sub
Public Class Form2 'Private imageDeFond As New Bitmap("image01.jpg") Private imageDeFond As New Bitmap(My.Computer.FileSystem.SpecialDirectories.MyDocuments & "\image01.jpg") 'L'image doit se trouver pour l'exemple dans le dossier de l'exécutable 'mais on pourrait aussi la mettre en ressources Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load ' End Sub Private Sub Form2_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint Dim maFonte As New Font("Microsoft Sans Serif", 12, FontStyle.Bold) 'Dessiner l'image e.Graphics.DrawImage(imageDeFond, 0, 0, imageDeFond.Width, imageDeFond.Height) 'Dessiner le texte "Coucou", avec maFonte, en noir, à la position (10,100) e.Graphics.DrawString("Coucou", maFonte, Brushes.Black, 10, 100) End Sub End Class
Dim maFonte As New Font("Microsoft Sans Serif", 12, FontStyle.Bold)
e.Graphics.DrawImage(My.Resources.Image01, 0, 0, imageDeFond.Width, imageDeFond.Height)
e.Graphics.DrawString("Coucou" & vbCrLf & "les amis !", maFonte, Brushes.Black, New Rectangle(10, 100, 200, 50))