How can i paint on the controls when the mouse is clicked on them? I tried creating a handler for Ctrl.paint but it didn't work. I want the image to be drawn over the control instead of under, like bringing it to the front..
Private Sub AllCtrls() Dim ExceptedCtrl = {StartLabel} For Each Ctrl As Control In Me.Controls.OfType(Of Control).Except(ExceptedCtrl) AddHandler Ctrl.Click, AddressOf Ctrl_Click Next End Sub Private Sub Ctrl_Click(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseDown Start() End Sub Private Sub Form1_Paint(sender As Object, e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint Static myImagePoints As New List(Of Point) Dim Intimg As New Bitmap(My.Resources.Image1, 42, 39) If DoPaint Then Dim CurrentPoint As New Point(CInt(Me.PointToClient(Cursor.Position).X - Intimg.Width / 2), CInt(Me.PointToClient(Cursor.Position).Y - Intimg.Height / 2)) myImagePoints.Add(CurrentPoint) DoPaint = False End If For Each EnteredPoint As Point In myImagePoints e.Graphics.DrawImage(Intimg, EnteredPoint) Next Intimg.Dispose() My.Resources.Image1.Dispose() End Sub End Class
Last edited by a moderator: