Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove If e.X > 365 And e.Y > 224 And e.X < 432 And e.Y < 237 Then 'la End If If e.X > 365 And e.Y > 256 And e.X < 432 And e.Y < 271 Then 'la End If If e.X > 365 And e.Y > 289 And e.X < 432 And e.Y < 303 Then 'la End If End Sub
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionLabel1.Parent = PictureBox1 Label1.BackColor = Color.Transparent
tu redessine ton imageElle se redessine grace a Me.invalidate, non ?
tu contrôle la position de la sourisIl faut que je recontrole dans l'événement Paint sauf que X et Y n'est pas un membre de 'System.Windows.Forms.PaintEventArgs'.
Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove If e.X > 365 And e.Y > 224 And e.X < 432 And e.Y < 237 Then End If If e.X > 365 And e.Y > 256 And e.X < 432 And e.Y < 271 Then End If If e.X > 365 And e.Y > 289 And e.X < 432 And e.Y < 303 Then End If End Sub Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint Dim maFonte As New Font("Comic Sans MS", 9, FontStyle.Bold) Dim maFonte2 As New Font("Comic Sans MS", 7, FontStyle.Bold) 'Dessiner l'image e.Graphics.DrawImage(My.Resources.Dom2, 99, 204) 'Dessiner le texte "Coucou", avec maFonte, en noir, à la position (10,100) e.Graphics.DrawString("...", maFonte, Brushes.Gray, 137, 213) e.Graphics.DrawString("...", maFonte, Brushes.Gray, 137, 245) e.Graphics.DrawString("...", maFonte, Brushes.Gray, 137, 280) e.Graphics.DrawString("...", maFonte2, Brushes.WhiteSmoke, 366, 225) e.Graphics.DrawString("...", maFonte2, Brushes.WhiteSmoke, 366, 258) e.Graphics.DrawString("...", maFonte2, Brushes.WhiteSmoke, 366, 289) End Sub
Private mLastMousePos as point=new point(0,0) Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove mLastMousePos =new point(e.X, e.Y) Me.Invalidate End Sub Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint Dim maFonte As New Font("Comic Sans MS", 9, FontStyle.Bold) Dim maFonte2 As New Font("Comic Sans MS", 7, FontStyle.Bold) 'Dessiner l'image e.Graphics.DrawImage(My.Resources.Dom2, 99, 204) 'Dessiner le texte "Coucou", avec maFonte, en noir, à la position (10,100) e.Graphics.DrawString("...", maFonte, Brushes.Gray, 137, 213) e.Graphics.DrawString("...", maFonte, Brushes.Gray, 137, 245) e.Graphics.DrawString("...", maFonte, Brushes.Gray, 137, 280) If mLastMousePos.X > 365 And mLastMousePos.Y > 224 And mLastMousePos.X < 432 And mLastMousePos.Y < 237 Then e.Graphics.DrawString("...", maFonte2, Brushes.WhiteSmoke, 366, 225) Else e.Graphics.DrawString("...", maFonte2, Brushes.WhiteSmoke, 366, 225) End If If mLastMousePos.X > 365 And mLastMousePos.Y > 256 And mLastMousePos.X < 432 And mLastMousePos.Y < 271 Then e.Graphics.DrawString("...", maFonte2, Brushes.WhiteSmoke, 366, 258) Else e.Graphics.DrawString("...", maFonte2, Brushes.WhiteSmoke, 366, 258) End If If mLastMousePos.X > 365 And mLastMousePos.Y > 289 And mLastMousePos.X < 432 And mLastMousePos.Y < 303 Then e.Graphics.DrawString("...", maFonte2, Brushes.WhiteSmoke, 366, 289) Else e.Graphics.DrawString("...", maFonte2, Brushes.WhiteSmoke, 366, 289) End If End Sub
''' C'est le graphique avec lequelle on va dessiner dans un premier temps, puis afficher Private BufferredGraphic As BufferedGraphics ''' C'est l'objet qui permet d'allouer de la mémoire tampon pour stockage du bitmap de dessin Private CurrentContext As New BufferedGraphicsContext #Region "Ouverture de la form" Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load BufferredGraphic = Me.CurrentContext.Allocate(Me.CreateGraphics(), Me.DisplayRectangle) End sub Private Sub Dessin() 'On dessine dans la mémoire BufferredGraphic.Graphics.DrawImage(My.Resources.Dofusm2, 99, 204) 'Déclenche l'évenement OnPaint de la fenêtre Me.Form1_Paint(Me, New PaintEventArgs(Me.BufferredGraphic.Graphics, Me.DisplayRectangle)) End Sub Private mLastMousePos As Point = New Point(0, 0) Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove mLastMousePos = New point(e.X, e.Y) Me.Invalidate() End Sub Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint Dim maFonte As New Font("Comic Sans MS", 9, FontStyle.Bold) Dim maFonte2 As New Font("Comic Sans MS", 7, FontStyle.Bold) 'Dessiner l'image BufferredGraphic.Render() 'Dessiner le texte "Coucou", avec maFonte, en noir, à la position (10,100) e.Graphics.DrawString("Boutique [ON] sur le site", maFonte, Brushes.Gray, 137, 213) e.Graphics.DrawString("Nouveau CMS sur le site.", maFonte, Brushes.Gray, 137, 245) e.Graphics.DrawString("Re-Ouverture du serveur Destyn'x", maFonte, Brushes.Gray, 137, 280) If mLastMousePos.X > 365 And mLastMousePos.Y > 224 And mLastMousePos.X < 432 And mLastMousePos.Y < 237 Then e.Graphics.DrawString("Plus d'infos...", maFonte2, Brushes.Blue, 366, 225) Else e.Graphics.DrawString("Plus d'infos...", maFonte2, Brushes.WhiteSmoke, 366, 225) End If If mLastMousePos.X > 365 And mLastMousePos.Y > 256 And mLastMousePos.X < 432 And mLastMousePos.Y < 271 Then e.Graphics.DrawString("Plus d'infos...", maFonte2, Brushes.Blue, 366, 258) Else e.Graphics.DrawString("Plus d'infos...", maFonte2, Brushes.WhiteSmoke, 366, 258) End If If mLastMousePos.X > 365 And mLastMousePos.Y > 289 And mLastMousePos.X < 432 And mLastMousePos.Y < 303 Then e.Graphics.DrawString("Plus d'infos...", maFonte2, Brushes.Blue, 366, 289) Else e.Graphics.DrawString("Plus d'infos...", maFonte2, Brushes.WhiteSmoke, 366, 289) End If End Sub
''' C'est le graphique avec lequelle on va dessiner dans un premier temps, puis afficher Private BufferredGraphic As BufferedGraphics ''' C'est l'objet qui permet d'allouer de la mémoire tampon pour stockage du bitmap de dessin Private CurrentContext As New BufferedGraphicsContext Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load BufferredGraphic = Me.CurrentContext.Allocate(Me.CreateGraphics(), Me.DisplayRectangle) End sub Private Sub Dessin() 'On dessine dans la mémoire BufferredGraphic.Graphics.DrawImage(My.Resources.Dofusm2, 99, 204) 'Déclenche l'évenement OnPaint de la fenêtre Me.Form1_Paint(Me, New PaintEventArgs(Me.BufferredGraphic.Graphics, Me.DisplayRectangle)) End Sub Private mLastMousePos As Point = New Point(0, 0) Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove mLastMousePos = New point(e.X, e.Y) Me.Invalidate() End Sub Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint Dim maFonte As New Font("Comic Sans MS", 9, FontStyle.Bold) Dim maFonte2 As New Font("Comic Sans MS", 7, FontStyle.Bold) 'Dessiner l'image BufferredGraphic.Render() 'Dessiner le texte "Coucou", avec maFonte, en noir, à la position (10,100) e.Graphics.DrawString("Boutique [ON] sur le site", maFonte, Brushes.Gray, 137, 213) e.Graphics.DrawString("Nouveau CMS sur le site.", maFonte, Brushes.Gray, 137, 245) e.Graphics.DrawString("Re-Ouverture du serveur Destyn'x", maFonte, Brushes.Gray, 137, 280) If mLastMousePos.X > 365 And mLastMousePos.Y > 224 And mLastMousePos.X < 432 And mLastMousePos.Y < 237 Then e.Graphics.DrawString("Plus d'infos...", maFonte2, Brushes.Blue, 366, 225) Else e.Graphics.DrawString("Plus d'infos...", maFonte2, Brushes.WhiteSmoke, 366, 225) End If If mLastMousePos.X > 365 And mLastMousePos.Y > 256 And mLastMousePos.X < 432 And mLastMousePos.Y < 271 Then e.Graphics.DrawString("Plus d'infos...", maFonte2, Brushes.Blue, 366, 258) Else e.Graphics.DrawString("Plus d'infos...", maFonte2, Brushes.WhiteSmoke, 366, 258) End If If mLastMousePos.X > 365 And mLastMousePos.Y > 289 And mLastMousePos.X < 432 And mLastMousePos.Y < 303 Then e.Graphics.DrawString("Plus d'infos...", maFonte2, Brushes.Blue, 366, 289) Else e.Graphics.DrawString("Plus d'infos...", maFonte2, Brushes.WhiteSmoke, 366, 289) End If End Sub