0

How can I overlay a transparent image that stay on top of anything in the form?

I tried various solutions but none do the job. A picturebox or a panel stays on top but no way to get alpha transparency to work.

The nearest result achived is with a custom control:

Public Class TransparentImage
    Private Sub TransparentImage_Paint(sender As Object, e As PaintEventArgs) Handles Me.Paint
        e.Graphics.DrawImage(My.Resources.Demo, 0, 0, 100, 100)
    End Sub

    Protected Overrides ReadOnly Property CreateParams() As CreateParams
        Get
            Dim cp As CreateParams = MyBase.CreateParams
            cp.ExStyle = cp.ExStyle Or &H20
            Return cp
        End Get
    End Property

End Class

I draw the png in the paint event. The result is good for the transparency but the overlay is deleted or partially deleted as soon as some control below updates (ex. a datagriview scroll).

mertie65
  • 3
  • 1
  • 1
    Per pixel alpha layered Form, [as shown here](https://stackoverflow.com/a/60688580/7444103), to use as an overlay. The advantage is that the System takes care of redrawing its content. You can only use semi-transparent bitmap, it doesn't support child Controls. See the notes there. – Jimi Jan 09 '21 at 17:13
  • It works! Thanks. Post as an answer i'll accept as solutions – mertie65 Jan 09 '21 at 19:03
  • I think I've already posted it :) – Jimi Jan 09 '21 at 19:13

0 Answers0