Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 42292

Changing transparent background image

$
0
0
I've made a program with a transparent background image using the following code in the form_load sub.
Code:

        Me.SetStyle(ControlStyles.SupportsTransparentBackColor, True)
        Me.BackColor = Color.Transparent
        Dim img As Bitmap = CType(Me.BackgroundImage, Bitmap)
        Me.FormBorderStyle = Windows.Forms.FormBorderStyle.None
        Me.TransparencyKey = img.GetPixel(2, 2)

I have a timer set to 1 second, that I want to use to change the background. I tried this code to change the picture every second.
Code:

            Beat = Beat + 1
            If Beat = 1 Then Me.BackgroundImage = My.Resources.ResourceManager.GetObject("Heart1.png")
            If Beat = 2 Then Me.BackgroundImage = My.Resources.ResourceManager.GetObject("Heart2.png") : Beat = 0

This causes the window to revert to grey.

Any ideas? Thanks.

Viewing all articles
Browse latest Browse all 42292

Trending Articles